我有一些數字添加整數列表或陣列filereading
File:
1
2
3
4
.txt文件我想有讀取這些數字,並將其添加到列表或陣列,它會顯示一個方法它在一個消息框中。
我有這樣的時刻:
public void LaadVrijeKamers()
{
int KamerNummers = Convert.ToInt32(File.ReadAllText(@"x\Vrijekamers.txt"));
MessageBox.Show(Convert.ToString(KamerNummers));
}
我得到在荷蘭的一個錯誤,說以下內容:
Can not read the characters
我覺得File.ReadAllText僅用於字符串,但我我不確定。也許我正在轉換錯誤。
嘗試不要使用像這樣的嵌套調用:ToInt32(File.ReadAllText)。 –