C# winform 判斷當前參數值與節點中的值是否一致
public static bool CheckValues(string isscreenshot, string screenshottime, string screenshotsavepath)
{
try
{
bool flage = false;
DataTable dt = ReturnTbByReradxml(basePath,"screenshot");
if (dt != null)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["isscreenshot"].ToString() == isscreenshot)
{
if (dt.Rows[i]["screenshottime"].ToString() == screenshottime)
{
if (dt.Rows[i]["screenshotsavepath"].ToString() == screenshotsavepath)
{
flage = true;
break;
}
}
}
}
return flage;
}
else
{
return flage;
}
}
catch
{
return false;
}
}
public static DataTable ReturnTbByReradxml(string fileName,string NodeName)
{
try
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
if (File.Exists(fileName))
{
ds.ReadXml(fileName);
if (ds == null)
{
return null;
}
else
{
dt = ds.Tables[NodeName];
return dt.Copy();
}
}
else
{
return null;
}
}
catch
{
return null;
}
}
basePath------------文件存儲路勁
isscreenshot, screenshottime, screenshotsavepath ,fileName,NodeName-----------------------節點名