You can get latest file or folder path from this function
public string getLatestDirectory(string path, string folderName)
{
FileInfo[] info = Directory.GetDirectories(path + "\\"+folderName).Select(x => new FileInfo(x)).OrderByDescending(x => x.LastWriteTime).Take(1).ToArray();
return Path.GetFullPath(info[0].Name);
}
public string getLatestDirectory(string path, string folderName)
{
FileInfo[] info = Directory.GetDirectories(path + "\\"+folderName).Select(x => new FileInfo(x)).OrderByDescending(x => x.LastWriteTime).Take(1).ToArray();
return Path.GetFullPath(info[0].Name);
}
No comments:
Post a Comment