是否可以搜索符合特定搜索条件的嵌入文件(例如* .xml)。
我的代码(仅适用于我知道路径的文件)
var fileName = "PATH.sample.xml";
var assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream(fileName);
StreamReader reader = new StreamReader(stream);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(reader.ReadToEnd());
答案 0 :(得分:5)
var findedResourceNames = assembly.GetManifestResourceNames()
.Where(name => name.EndsWith(".xml")).ToArray();
答案 1 :(得分:1)
string[] files = System.IO.Directory.GetFiles("yourPath", "*.xml");
foreach (string file in files)
{
//do what you need here
}