C# 如何提取SaveFileDialog的保存路径?
1 public TestOne() 2 { 3 InitializeComponent(); 4 SaveFileDialog();//调用打开SaveFileDialog 保存对话框 5 } 6 #region 保存对话框 7 private void SaveFileDialog() 8 { 9 //string localFilePath, fileNameExt, newFileName, FilePath; 10 SaveFileDialog saveFileDialog1 = new SaveFileDialog(); //设置文件类型 11 saveFileDialog1.Filter = " txt files(*.txt)|*.txt|All files(*.*)|*.*"; //设置默认文件类型显示顺序 12 saveFileDialog1.FilterIndex = 2; //保存对话框是否记忆上次打开的目录 13 saveFileDialog1.RestoreDirectory = true; //点了保存按钮进入 14 if (saveFileDialog1.ShowDialog() == DialogResult.OK) 15 { 16 //获得文件路径 17 //localFilePath = saveFileDialog1.FileName.ToString(); 18 //获取文件名,不带路径 19 //fileNameExt = localFilePath.Substring(localFilePath.LastIndexOf("\\") + 1); 20 //获取文件路径,不带文件名 21 //FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\\")); 22 //给文件名前加上时间 23 //newFileName = DateTime.Now.ToString("yyyyMMdd") + fileNameExt; 24 //在文件名里加字符 25 //saveFileDialog1.FileName.Insert(1,"dameng"); 26 System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile(); 27 //输出文件 28 //fs输出带文字或图片的文件,就看需求了 29 } 30 } 31 #endregion
C# 如何提取SaveFileDialog的保存路径?
检举|
2009-05-28 11:37