選擇文件夾
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); }