Description:
Following code can be used to get file information in a folder:
static void getfileinfo()
{
    string path = "D:\\test\\";
    String[] filenames = Directory.GetFiles(path, "*.txt");
    string file = string.Empty;
    string name = string.Empty;
    DateTime creationTime;
    DateTime lastWriteTime;
    DateTime lastAccessTime;
    foreach (string str in filenames)
    {
        creationTime
= File.GetCreationTime(str);
       
lastWriteTime = File.GetLastWriteTime(str);
       
lastAccessTime = File.GetLastAccessTime(str);
        file =
str.Substring(str.LastIndexOf("\\") + 1);
        name =
file.Substring(0, file.IndexOf('.')).Replace("-", " ").Trim();
    }
}
 
 
 
No comments:
Post a Comment