开发者

Date Range wildcard

开发者 https://www.devze.com 2023-01-12 18:23 出处:网络
Ok so I have these xml files that have date ranges on them. Heres an example: System.IO.File.Move(files[i], \"C:\\\\Checks\\\\XMLFiles\\\\\" +

Ok so I have these xml files that have date ranges on them. Heres an example:

System.IO.File.Move(files[i], "C:\\Checks\\XMLFiles\\" + 
    DateTime.Now.ToString("MM-dd-yyyy-hhmmssfff") + ".xml");

What I want to do is to format it in such a way where the NOW will be just todays date, and the hhmmssfff will be a wildcard, basically showing me everything from just today.

Any ideas here? Im a newbie so sorry if its a stupid question.

Thanks!

System.IO.File.Move(files[i], "C:\\Checks\\XMLFiles\\" + 
    DateTime.Now.ToString("MM-dd-yyyy-") + ________ + ".xml");

Oh here are a couple of the file names just for reference:

08-24-2010-123701072

08-24-2010-124852164

08-24-2010-123715462

08-24-2010-123348784

08-23-2010-124607792

Below is my orginal code:

protected void Button3_Click(object sender, EventArgs e) { { Response.ContentType = "application/vnd.ms-excel"; 开发者_JS百科 Response.Charset = ""; DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("checks.xml")); XmlDataDocument xdd = new XmlDataDocument(ds); XslTransform xt = new XslTransform(); xt.Load(Server.MapPath("WellsFargoFile.xsl")); xt.Transform(xdd, null, Response.OutputStream); Response.End(); }

I want to remove checks.xml and insert something that has some sort of date range, just minus the hours seconds, etc. So the code that I found would work.


I think what you're looking for is something like the Directory.GetFiles method that takes a wildcard:

Directory.GetFiles(@"C:\Checks\XMLFiles\", DateTime.Now.ToString("MM-dd-yyyy-*.xml"))

That will get the list of all files in the directory for that given day, then you can loop through the return of that calling File.Move on each of those.


Why not just omit the hhmmssfff portion and and leave it as the date only?

System.IO.File.Move(files[i], @"C:\Checks\XMLFiles\" + DateTime.Now.ToString("MM-dd-yyyy-") + ".xml");
0

精彩评论

暂无评论...
验证码 换一张
取 消