c# 打開、保存文件對話框 和 文件夾選擇對話框


1、

 

 OpenFileDialog openImageDialog = new OpenFileDialog();
 openImageDialog.Filter = "Image Files (*.jpg;*.png)|*.jpg;*.png";
 openImageDialog.Multiselect = false;

 if (openImageDialog.ShowDialog() == DialogResult.OK)
 {
    MessageBox.Show(openImageDialog.FileName);
 }
 else
 {
 }
 SaveFileDialog saveImageDialog = new SaveFileDialog();
  saveImageDialog.Filter = "Image Files (*.jpg;*.png)|*.jpg;*.png";
   //openImageDialog.Multiselect = false;

   if (saveImageDialog.ShowDialog() == DialogResult.OK)
   {
       MessageBox.Show(saveImageDialog.FileName);
   }
   else
   {
   }

2、文件夾選擇對話框

FolderBrowserDialog folderDlg = new FolderBrowserDialog();
if(folderDlg.ShowDialog()==DialogResult.OK)
    MessageBox.Show(folderDlg.SelectedPath);

---恢復內容結束---


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM