📄 importdata.cs
字号:
using System;
using System.Data;
using System.Windows.Forms;
namespace train
{
/// <summary>
/// ImportData :导入数据
/// </summary>
public class ImportData
{
private DataSet ds;
private DataTable table;
public ImportData()
{
ds=new DataSet();
table=new DataTable();
}
/// <summary>
/// 从XML文件导入数据
/// </summary>
/// <returns>返回包含数据的DataTable</returns>
public DataTable ImportDataFromXml()
{
OpenFileDialog dialog=new OpenFileDialog();
dialog.Filter="XML文件|*.xml";
dialog.ShowDialog();
string path=dialog.FileName;
if(path.Length==0)
{
return null;
}
try
{
ds.ReadXml(@path,XmlReadMode.Auto);
return ds.Tables[0];
}
catch(Exception e)
{
Console.WriteLine(e.Message);
return null;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -