Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a resource file with StreamReader?

Tags:

c#

This doesnt work:

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

How do you open a resource file to get its contents?

like image 432
Bramble Avatar asked May 29 '26 22:05

Bramble


1 Answers

Try like this:

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];
    }
}
like image 123
Darin Dimitrov Avatar answered Jun 01 '26 11:06

Darin Dimitrov