System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
openFileDialog.Filter = "DataBank(*.xml)|*.xml|全部文件(*.*)|*.*";
openFileDialog.Multiselect = true;//是否允许多选,false表示单选
System.Windows.Forms.DialogResult dr = openFileDialog.ShowDialog();
if (dr == System.Windows.Forms.DialogResult.OK)
{undefined
//openFileDialog.FileNames 获取对话框中所有选定文件的文件名(String 类型数组),为绝对路径,类似"E:\\code\\123.xml"
foreach(var FileName in openFileDialog.FileNames)
{undefined
System.IO.FileInfo file = new System.IO.FileInfo(FileName);//如果是单选,FileName=openFileDialog.FileName
if (file.Extension == ".xml")
{undefined
GetFileData(FileName);//根据文件名路径获取文件数据逻辑
}
else
{undefined
MessageBox.Show("请选择xml文件,目前仅支持对xml数据读取!");
return;
}
}
}
————————————————
版权声明:本文为CSDN博主「hx_windy」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/hx_windy/article/details/92773717