c#winform選擇文件/文件夾/打開指定目錄方法


選擇文件夾

        private void btnSelete_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dialog = new FolderBrowserDialog();
            dialog.Description = "請選擇文件路徑";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                lblSelete.Text = dialog.SelectedPath;
            }
        }

打開文件夾

            //打開文件夾
            System.Diagnostics.Process.Start("explorer.exe", lblSelete.Text+@"\");

選擇文件

OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = true;
fileDialog.Title = "請選擇文件";
fileDialog.Filter="所有文件(*.*)|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
string file=fileDialog.FileName;
MessageBox.Show("已選擇文件:" + file,"選擇文件提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}

 


免責聲明!

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



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