//顯示Dlg 儲存txt檔
ArrayList alWorkPoint = new ArrayList();
alWorkPoint.clear();
SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "save"; dialog.InitialDirectory = ".\\"; dialog.FileName = "new.txt"; dialog.Filter = "txt file (*.*)|*.txt"; if (dialog.ShowDialog() == DialogResult.OK) { StreamWriter filew = new StreamWriter((dialog.FileName)); DecoderListView(); for (int i = 0; i < alWorkPoint.Count; i++) { filew.WriteLine(alWorkPoint[i].ToString()); } filew.Close(); MessageBox.Show("save ok"); }
//--------直接存檔 指定檔名
StreamWriter filew = new StreamWriter(("new.txt")); filew.WriteLine("hello"); filew.WriteLine("world"); filew.WriteLine(DateTime.Now); filew.Close();測試環境:vs2015 c#.net
沒有留言:
張貼留言