12,162
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 获取XML数据库中的数据的方法
/// </summary>
/// <param name="strFilePath">传入文件路径</param>
/// <returns>返回一个数据集</returns>
public static DataSet GetAllDataFromXML(string strFilePath)
{
DataSet ds = new DataSet();
FileInfo fileInfo = new FileInfo(strFilePath);
if (fileInfo.Exists)
{
try
{
ds.ReadXml(strFilePath);
}
catch { }
}
else
{
ds = null;
}
if (ds != null)
{
if (ds.Tables[0].Rows.Count < 1)
ds = null;
}
return ds;
}