这并不工作:使用StreamReader打开资源文件?
string fileContent = Resource.text;
StreamReader read = File.OpenText(fileContent);
string line;
char[] splitChar = "|".ToCharArray();
while ((line = read.ReadLine()) != null)
{
string[] split = line.Split(splitChar);
string name = split[0];
string lastname = split[1];
}
read.Dispose();
如何打开一个资源文件,以获取其内容是什么?
什么是“不工作”意思?它是否会抛出异常?它是否默默地失败? – 2011-04-08 18:14:27
请参阅:http://stackoverflow.com/questions/5342975/get-a-textreader-from-a-stream/5343005#5343005 – 2011-04-08 18:14:53
资源文件通常是一个二进制文件。用StreamReader读取它可能不会给你想要的信息。请参阅@Arnaud F.提供的用于从流中读取文本资源的答案。 – 2011-04-08 18:23:02