To load text from file to string you can use StreamReader.ReadToEnd method. First create new instance of StreamReader. As a parameter in constructor you can pass string with file path or Stream instance. Default encoding is UTF-8.
using System.IO;
StreamReader streamReader = new StreamReader(filePath);
string text = streamReader.ReadToEnd();
streamReader.Close();
using System.IO;
StreamReader streamReader = new StreamReader(filePath);
string text = streamReader.ReadToEnd();
streamReader.Close();
No comments:
Post a Comment