使用StreamReader打开资源文件?

Bra*_*ble 2 c#

这不起作用:

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();
Run Code Online (Sandbox Code Playgroud)

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

Dar*_*rov 5

试试这样:

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];
    }
}
Run Code Online (Sandbox Code Playgroud)