C#选择文件(OpenFileDialog)、选择文件夹(FolderBrowserDialog)
2021-03-18 11:24
标签:扩展名 get 文件 san 12px size extension filedia str 1 选择文件(OpenFileDialog) 2 选择文件夹(System.Windows.Forms.FolderBrowserDialog) C#选择文件(OpenFileDialog)、选择文件夹(FolderBrowserDialog) 标签:扩展名 get 文件 san 12px size extension filedia str 原文地址:https://www.cnblogs.com/pu369/p/12358284.html OpenFileDialog dialog = new OpenFileDialog();
//dialog.Multiselect = true;//该值确定是否可以选择多个文件
// dialog.Title = "请选择文件";
//dialog.Filter = "所有文件(*.*)|*.*";
//dialog.InitialDirectory = @"E:\";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string fullFileName = dialog.FileName;// @"e:\日记.doc";
//var FileName =System.IO.Path.GetFileName(fullFileName); //文件名 “日记.doc”
//string extension = System.IO.Path.GetExtension(fullFileName);//扩展名 “.doc”
//string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fullFileName);// 没有扩展名的文件名 “日记”
}
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.Description = "请选择Txt所在文件夹";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{ string path = dialog.SelectedPath; // "e:/go"
}
文章标题:C#选择文件(OpenFileDialog)、选择文件夹(FolderBrowserDialog)
文章链接:http://soscw.com/index.php/essay/65752.html