打开文件:
/// <summary>
/// 打开文件
/// </summary>
/// <returns>文件路径</returns>
private string OpenFiles()
{
string file_path = "";
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Multiselect = true;
fileDialog.Title = "请选择文件";
fileDialog.Filter = "所有文件(*.*)|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
file_path = fileDialog.FileName;
}
return file_path;
}
打开文件夹:
/// <summary>
/// 打开文件夹
/// </summary>
/// <returns>文件夹路径</returns>
private string OpenForlder()
{
string file_path = "";
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "请选择文件路径";
if (dialog.ShowDialog() == DialogResult.OK)
{
file_path = dialog.SelectedPath;
}
return file_path;
}