[英]Iterate through a text file line by line c#
基本上这是我目前拥有的代码;
public async void readTextFile()
{
try {
StorageFolder folder = KnownFolders.VideosLibrary;
StorageFile storageFile = await folder.GetFileAsync("students.txt");
string text = await Windows.Storage.FileIO.ReadTextAsync(storageFile);
} catch (Exception e) {
the_name.Text = "{0} Exception caught." + e;
}
}
}
文本文件具有这样排列的学生列表
学生姓名|假
学生第二|假
如果有10名学生的名字和单词false,以指定他们是否已在应用程序中参加考试,如果他们接受了false,则会还原为true。
我的问题是什么。 如何遍历该文本文件中的每一行,并将在文本框中键入的内容存储在变量中?
请注意:我正在创建Windows桌面商店应用程序
提前致谢!
代替使用ReadTextAsync方法,可以使用ReadLinesAsync方法,然后遍历结果并分割管道字符以查找所需内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.