我需要从资源中读取文件并将其添加到列表中。 我的代码:
private void Form1_Load(object sender, EventArgs e)
{
using (StreamReader r = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("myProg.myText.txt")))
{
//The Only Options Here Are BaseStream & CurrentEncoding
}
}
我搜索过这个,只得到了像 "Assembly.GetExecutingAssembly...."
这样的答案,但我的程序没有 Assembly 选项。?
最佳答案
尝试这样的事情:
string resource_data = Properties.Resources.test;
List<string> words = resource_data.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries).ToList();
在哪里
关于c# - 从 C# 资源中读取文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15722455/