2020-03-22 每日一例第13天
1.新建对话框,拖Textbox/label/button;
2.“选择文件”按钮后的代码;
OpenFileDialog op1 = new OpenFileDialog();
op1.Title = "选择数据文件";
op1.Filter = "所有文件|*.*|Excel表格|*.xls;*.xlsx";
op1.Multiselect = true;
if (op1.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
text1.Text = op1.FileName;
}
3.“选择文件夹”按钮后的代码;
FolderBrowserDialog fd2 = new FolderBrowserDialog();
fd2.Description = "请选择一个文件夹";
fd2.RootFolder = Environment.SpecialFolder.Desktop;
fd2.ShowNewFolderButton = false;
if (fd2.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
text2.Text = fd2.SelectedPath;
}