This project is read-only.

Sorting Albums and Photos by Filename

Aug 11, 2007 at 10:12 PM
Hello all,

Some people are likely wondering how to get their photos and albums sorted by the filename instead of the modified date. This is particularly useful if you already have all the files named in the exact order you want them displayed in, such as when uploaded to your PC using the Microsoft Scanner and Camera Wizard.

I hope Bertrand will include this 'sort by name' feature in the next release of PhotoHandler. In the meantime, I have pasted below some fairly straighforward instructions on how to get it working, assuming you are starting from version 2.1 of the PhotoHandler.

By the way - if anyone can suggest alternative or better ways of achieving the same effect - please reply!

1 - Open the album.ashx file for editing (i.e. Notepad or Visual Studio)
2 - Navigate to the method called GetImageDate (it's around line # 1102)
3 - Paste in a new method below GetImageDate, with the following code:
/// <summary>
/// Returns the file name of the selected image.
/// </summary>
/// <param name="pictureFileInfo">The FileInfo for the image.</param>
/// <returns>The filename.</returns>
internal static String GetImageFileName(FileInfo pictureFileInfo)
return pictureFileInfo.Name;
4 - Find the following line of code in the method GetImages (near line # 2053)
return ImageInfo.GetImageDate(x).CompareTo(ImageInfo.GetImageDate(y));
5 - Replace that line of code with this line:
return ImageInfo.GetImageFileName(x).CompareTo(ImageInfo.GetImageFileName(y));

That's all there is to it. Hope this helps anyone looking to sort by filename.