查找dll中的路径
Find the path in dll
我的项目中有一个 dll 文件作为资源。现在我想访问dll中的目录文件夹。
例如。图像 dll(在 Image.dll -> \Image\PresetFolder)
我想Directory.Getdirectories()文件夹路径在Image.dll
我怎样才能在 C# 中实现这个???
终于,朋友给了我答案,你必须先加载dll,然后才能用代码获取目录路径
private string[] GetAllResourcePath()
{
Assembly assembly = Assembly.Load("ImageDLL");
string resName = "ImageDLL.g.resources";
using (var stream = assembly.GetManifestResourceStream(resName))
{
using(var reader = new ResourceReader(stream))
{
return reader.Cast<DictionaryEntry>().Select(x => (string)x.Key).ToArray();
}
}
}
从这个func中,它会return所有的资源目录路径,你可以用.Where() linq过滤掉你想要的目录。
我的项目中有一个 dll 文件作为资源。现在我想访问dll中的目录文件夹。 例如。图像 dll(在 Image.dll -> \Image\PresetFolder)
我想Directory.Getdirectories()文件夹路径在Image.dll
我怎样才能在 C# 中实现这个???
终于,朋友给了我答案,你必须先加载dll,然后才能用代码获取目录路径
private string[] GetAllResourcePath()
{
Assembly assembly = Assembly.Load("ImageDLL");
string resName = "ImageDLL.g.resources";
using (var stream = assembly.GetManifestResourceStream(resName))
{
using(var reader = new ResourceReader(stream))
{
return reader.Cast<DictionaryEntry>().Select(x => (string)x.Key).ToArray();
}
}
}
从这个func中,它会return所有的资源目录路径,你可以用.Where() linq过滤掉你想要的目录。