gpt4 book ai didi

c# - 文件阅读器卡住我的程序

转载 作者:太空宇宙 更新时间:2023-11-03 20:16:43 24 4
gpt4 key购买 nike

我无法确定为什么我的程序在运行以下方法时卡住:

String fileName = "Drops.de";
StreamReader streamReader = new StreamReader(fileName);
String npcName;
string npcID;
string itemID;
string itemAmount;
string itemRarity;
string itemName;

while(!streamReader.EndOfStream){
string line = streamReader.ReadLine();
//start of block
if(line.StartsWith("[")){
npcName = line.TrimStart('[');
npcName = npcName.TrimEnd(']');
while(npcName == button1.Text){
while(!line.StartsWith("[/")){
line = streamReader.ReadLine();
String[] s = line.Split(' ');
npcID = (s[0]);
itemName = (s[1]);
itemID = (s[2]);
itemAmount = (s[3]);
itemRarity = (s[4]);
dataGridView1.Rows.Add(itemName, itemID, itemAmount, itemRarity);
/*
DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
row.Cells[0].Value = itemName;
row.Cells[1].Value = itemID;
row.Cells[2].Value = itemAmount;
row.Cells[3].Value = itemRarity;
dataGridView1.Rows.Add(row);*/
dataGridView1.Refresh();
line = streamReader.ReadLine();
//MessageBox.Show(npcName);
}
}

}
}
streamReader.Close();
}

我怀疑它与“while”循环有关。但是我很可能是错的。我对编程很陌生,所以这可能是显而易见的事情 :p。

无论如何,我们将不胜感激 :)

最佳答案

你会退出这个循环while(npcName == button1.Text){吗? :-)

关于c# - 文件阅读器卡住我的程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16207312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com