The above is not grabbing an "embedded" file, it's grabbing all .txt
files located in the same directory as the running application.
If you're interested in the directory of another Assembly
, you need to get that other Assembly
. This can be done if you have a reference to the Assembly and know a public class
(ex: SomeType
) within the Assembly:
var path = typeof(SomeType).Assembly.Location;
var folder = new FileInfo(path).DirectoryName;
var files = Directory.GetFiles(folder, "*.txt").OrderBy(x => x).ToList();
Depending on the assembly, there might also be some data on your system, such as an environment variable or a GAC Entry.
If you don't have the assembly referenced or know that the file is keeping special flags in the system, you'll have to have some other way to get it, which becomes little different than simply knowing the path by putting it in a configuration file, database, or similar resource.