Hi, thanks for the time, but I already figured my way out on this.
My problem (at that time) is I have to get the last modified file in a folder and display in a label the DateTime value. My idea is to get all the files in that particular folder and compare each Date Modified of the files. I use the following codes.
using System.IO;
FileInfo objFileInfo;
DateTime dtLastModified;
dtLastModified = new DateTime (2001, 1, 1) ;
foreach (string s in Directory.GetFiles(Server.MapPath("~")))
{
objFileInfo = new FileInfo(s);
if (objFileInfo.LastWriteTime > dtLastModified)
{
dtLastModified = objFileInfo.LastWriteTime;
}
}
lblLastModified.Text = dtLastModified.ToString();
I don't know if I have the correct logic but this simply works for now.
(Maybe this could be a help to others... ΓΌ)
Enter your message below
Sign in or Join us (it's free).