我想選擇一個簡單的.txt文件,其中包含使用FileUpload控件的字符串行。但不是實際保存文件,我想循環每行文本,並在ListBox控件中顯示每行。通過FileUpload控件上傳txt文件的循環槽線
一個文本文件的例子:
的test.txt
123jhg345
182bdh774
473ypo433
129iiu454
什麼是實現這一目標的最佳方式是什麼?
我到目前爲止有:
private void populateListBox()
{
FileUpload fu = FileUpload1;
if (fu.HasFile)
{
//Loop trough txt file and add lines to ListBox1
}
}
感謝Shalini, 這就是我一直在尋找。請注意,流讀取器需要初始化爲: ** StreamReader reader = new StreamReader(fu.PostedFile.InputStream); ** – PercivalMcGullicuddy
感謝您的朋友。你救了我的一天。 –