//彈跳出DLG 選擇TXT檔案 讀取字串
ArrayList alWorkPoint = new ArrayList();
//System.Windows.Forms.ListView listView_CM; 宣告的Listview元件
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = "Select file";
dialog.InitialDirectory = ".\\";
dialog.Filter = "txt files (*.*)|*.txt";
if (dialog.ShowDialog() == DialogResult.OK)
{
StreamReader filer = new StreamReader((dialog.FileName));
alWorkPoint.Clear();
listView_CM.Items.Clear();
string str;
while ((str = filer.ReadLine()) != null)
{
alWorkPoint.Add(str);
}
DecoderFileToListView();
filer.Close();
}
//指定檔名,讀取單一檔案
StreamReader filer = new StreamReader(("new.txt"));
string str;
while((str = filer.ReadLine()) != null)
{
MessageBox.Show(str);
}
測試環境:vs2015 c#.net
沒有留言:
張貼留言