我正在为Windows 8桌面构建应用程序,我正在阅读文本文件,并且想要更改一个特定行,但不知道如何如此,因此我拥有的是文本文件说用c删除文本文件中的特定行#
username|false
username|false
username|false
而我想要删除中间的一行时,这是我到目前为止;
StorageFolder folder = ApplicationData.Current.LocalFolder;
StorageFile storageFile = await folder.GetFileAsync("students.txt");
var text = await Windows.Storage.FileIO.ReadLinesAsync(storageFile);
var list_false = "";
foreach (var line in text)
{
string name = "" + line.Split('|')[0];
string testTaken = "" + line.Split('|')[1];
if (your_name.Text == name)
{
if (testTaken == "false") {
pageTitle.Text = name;
enter_name_grid.Opacity = 0;
questions_grid.Opacity = 1;
var md = new MessageDialog("Enjoy the test");
await md.ShowAsync();
}
else
{
the_name.Text = "You have already taken the test";
var md1 = new MessageDialog("You have already taken the test");
await md1.ShowAsync();
}
return;
}
else
{
list_false = "You're not on the list";
}
}
if (list_false == "You're not on the list") {
var md2 = new MessageDialog("You're not on the list");
await md2.ShowAsync();
}
请帮助,它完美地读取名称,并允许他们接受测试,我只是需要它来删除正确的行。提前致谢!!
你是什么意思“去掉中间线有事时”? – Tarec
@Tarec嗯,当他们输入他们的名字时,如果有匹配,那么我想要删除与他们名字相对应的行 – user3263978