读取
.txt
文件一般分为全部读取和按行读取:
(一)全部读取
string testTxt = File.ReadAllText(@"D:\picture\standardStyle\test.txt", Encoding.Default);
//testTxt的使用
(二)按行读取
string path = @"D:\picture\standardStyle\test.txt";
StreamReader sr = new StreamerReader(path, Encoding.Default);
while((line = sr.ReadLine())!=null)
{
//对line进行操作
}