WPF 選擇文件,文件夾生成路徑


查找文件路徑
              private void stackPanel1_Click(object sender, EventArgs e)
              {
                  //查找文件路徑
                OpenFileDialog d = new OpenFileDialog();
                if (d.ShowDialog() == true) // Result could be true, false, or null
                folderName = d.FileName;
                textBox1.Text = folderName;
              
              }

查找文件夾路徑
必須手動加載  System.Windows.Forms.dll
瀏覽添加:
 C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Windows.Forms.dll

FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
            if (folderBrowser.ShowDialog() == DialogResult.OK)
            {
                DataStore.AddFolder(folderBrowser.SelectedPath);
            }

 


免責聲明!

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



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