如何从所有xml文件中搜索txtnumber并获取包含数字的文件。搜索所有目录和子目录。仅显示dateTimeStr等于和大于directorylast修改日期
var dateTimeStr = "11/04/2016 12:31";
var user_time = DateTime.Parse(dateTimeStr);
var dateTimeStr2 = "22/03/2016 16:34";
var user_time2 = DateTime.Parse(dateTimeStr2);
DirectoryInfo info = new DirectoryInfo(path);
DataSet dss = null;
if (info.LastWriteTime >= user_time)
{
var allfiles = Directory.GetFiles(path, "*.xml", System.IO.SearchOption.AllDirectories);
foreach (var item in allfiles)
{
DateTime lastModified = System.IO.File.GetLastWriteTime(item);
//string extension;
//extension = Path.GetExtension(item);
if (lastModified.ToShortTimeString() == user_time2.ToShortTimeString())
{
XmlReader xmlFile;
xmlFile = XmlReader.Create(item, new XmlReaderSettings());
dss = new DataSet();
DataView dv;
dss.ReadXml(xmlFile);
string time = dss.Tables[0].Rows[0]["starttime"].ToString();
string number = dss.Tables["Party"].Rows[0]["number"].ToString();
time = time.Substring(0, 19);
var getxmldate = time;
var datetimecheck = DateTime.Parse(getxmldate);
if (datetimecheck.ToShortTimeString() == user_time2.ToShortTimeString() && number =="202")
{
string filename = dss.Tables["recording"].Rows[0]["filename"].ToString();
string pathwav = item.Replace(".xml", ".wav");
using (SoundPlayer player = new SoundPlayer(pathwav))
{
// Use PlaySync to load and then play the sound.
// ... The program will pause until the sound is complete.
player.PlaySync();
}
// Process.Start(item + ".wav");
}
}
}
}