gpt4 book ai didi

c# - 用 StreamReader 打开资源文件?

转载 作者:行者123 更新时间:2023-11-30 15:08:25 24 4
gpt4 key购买 nike

这行不通:

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();

如何打开资源文件以获取其内容?

最佳答案

像这样尝试:

string fileContent = Resource.text;
using (var reader = new StringReader(fileContent))
{
string line;
while ((line = reader.ReadLine()) != null)
{
string[] split = line.Split('|');
string name = split[0];
string lastname = split[1];
}
}

关于c# - 用 StreamReader 打开资源文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5599111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com