static uint GetDirectoryIndex(string path)
{
var name = Path.GetFileName(path);
var dir = Path.GetDirectoryName(path);
return (uint)new DirectoryInfo(dir).GetFileSystemInfos()
.OrderBy(_ => _.Name)
.Select((info, index) => new { Info = info, Index = index })
.Single(_ => object.Equals(_.Info.Name, name)).Index;
}