收集 C# Dialog 以备以后使用。
1: FolderBrowserDialog 类 目标路径
效果图:
代码:
string
pfxfile
=
""
;
FolderBrowserDialog dialog = new FolderBrowserDialog();
if (dialog.ShowDialog( this ) == DialogResult.OK)
{
pfxfile = dialog.SelectedPath;
}
FolderBrowserDialog dialog = new FolderBrowserDialog();
if (dialog.ShowDialog( this ) == DialogResult.OK)
{
pfxfile = dialog.SelectedPath;
}
2:OpenFileDialog类 选择文件
string
pfxfile
=
""
;
OpenFileDialog fileDialog1 = new OpenFileDialog();
fileDialog1.Filter = " 文件类型(*.xml,*.txt,*.config)|*.xml;*.txt;*.config|All files (*.*)|*.* " ;
fileDialog1.FilterIndex = 1 ;
fileDialog1.RestoreDirectory = true ;
if (fileDialog1.ShowDialog() == DialogResult.OK)
{
pfxfile = fileDialog1.FileName;
}
OpenFileDialog fileDialog1 = new OpenFileDialog();
fileDialog1.Filter = " 文件类型(*.xml,*.txt,*.config)|*.xml;*.txt;*.config|All files (*.*)|*.* " ;
fileDialog1.FilterIndex = 1 ;
fileDialog1.RestoreDirectory = true ;
if (fileDialog1.ShowDialog() == DialogResult.OK)
{
pfxfile = fileDialog1.FileName;
}
TreeView