Some fixes -- DirHandle isn't behaving as expected.

This commit is contained in:
DarkFeather
2017-03-30 19:14:29 -05:00
parent 60de762c8b
commit 83d4717be2
4 changed files with 62 additions and 14 deletions

View File

@@ -42,6 +42,42 @@ namespace AniNIX.Shared {
return new List<String>(Directory.GetFiles(@_path));
}
/// <summary>
/// Get the path of the newest file.
/// </summary>
/// <returns>A List of strings</returns>
public String GetNewest() {
try {
return this.SortedListOfFiles()[0].FullName.Trim();
} catch (Exception e) {
e.ToString();
return null;
}
}
/// <summary>
/// Get the path of the oldest file
/// </summary>
/// <returns>A List of strings</returns>
public String GetOldest() {
try {
FileInfo[] files = this.SortedListOfFiles();
return files[files.Length-1].FullName.Trim();
} catch (Exception e) {
e.ToString();
return null;
}
}
/// <summary>
/// Sorts the list of files from newest to oldest.
/// </summary>
/// <returns>A List of strings</returns>
private FileInfo[] SortedListOfFiles() {
return (new DirectoryInfo(@_path)).GetFiles().OrderByDescending(p => p.CreationTime).ToArray();
}
/* IDisposable */
/// <summary>