C # how to extract the Save path of SaveFileDialog,
Directly Add code
1 public TestOne () 2 {3 InitializeComponent (); 4 SaveFileDialog (); // call to open the SaveFileDialog save dialog box 5} 6 7 # region save Dialog Box 8 private void SaveFileDialog () 9 {10 // string localFilePath, fileNameExt, newFileName, FilePath; 11 SaveFileDialog saveFileDialog1 = new SaveFileDialog (); 12 13 // set the file type 14 saveFileDialog1.Filter = "txt files (*. txt) | *. txt | All files (*. *) | *. * "; 15 16 // set the display sequence of the default file type 17 saveFileDialog1.FilterIndex = 2; 18 19 // whether to remember the last opened directory 20 saveFileDialog1.RestoreDirectory = true in the SAVE dialog box; 21 22 // click the Save button to enter 23 if (saveFileDialog1.ShowDialog () = DialogResult. OK) 24 {25 // get file path 26 // localFilePath = saveFileDialog1.FileName. toString (); 27 28 // get the file name without path 29 // fileNameExt = localFilePath. substring (localFilePath. lastIndexOf ("\") + 1); 30 31 // get the file path without the file name 32 // FilePath = localFilePath. substring (0, localFilePath. lastIndexOf ("\"); 33 34 // Add time 35 before the file name // newFileName = DateTime. now. toString ("yyyyMMdd") + fileNameExt; 36 37 // Add character 38 to the file name // saveFileDialog1.FileName. insert (1, "dameng"); 39 40 System. IO. fileStream fs = (System. IO. fileStream) saveFileDialog1.OpenFile (); // output file 41 42 // fs output file with text or image, depending on the requirement 43} 44}