// replace App with a class that is in the project where the embedded resource is.
var assembly = typeof(App).GetTypeInfo().Assembly;
// replace App3 with the namespace where your file is
var stream = assembly.GetManifestResourceStream("App3.XMLFile1.xml");
var lines = new List<string>();
using var reader = new StreamReader(stream);
while (reader.ReadLine() is { } line)
{
lines. Add(line);
}
1条答案
按热度按时间zi8p0yeb1#
您需要从嵌入资源所在的程序集中获取流。下面是如何读取它的示例代码。