title: Sort FileSystemInfo[] by Name
body: <p>I have probably spent about 500 hours Googling this and reading MSDN documentation and it still refuses to work the way I want.</p>
  
  <p>I can sort by name for files like this:</p>
  
  <pre><code>01.png
  02.png
  03.png
  04.png
  </code></pre>
  
  <p>I.e. all the same file length.</p>
  
  <p>The second there is a file with a longer file length everything goes to hell.</p>
  
  <p>For example in the sequence:</p>
  
  <pre><code>1.png
  2.png
  3.png
  4.png
  5.png
  10.png
  11.png
  </code></pre>
  
  <p>It reads:</p>
  
  <pre><code>1.png, 2.png then 10.png, 11.png
  </code></pre>
  
  <p>I don't want this.</p>
  
  <p>My Code:</p>
  
  <pre><code>DirectoryInfo di = new DirectoryInfo(directoryLoc);
  FileSystemInfo[] files = di.GetFileSystemInfos("*." + fileExtension);
  Array.Sort&lt;FileSystemInfo&gt;(files, new Comparison&lt;FileSystemInfo&gt;(compareFiles));
  
  foreach (FileInfo fri in files)
  {
      fri.MoveTo(directoryLoc + "\\" + prefix + "{" + operationNumber.ToString() + "}" + (i - 1).ToString("D10") +
          "." + fileExtension);
  
      i--;
      x++;
      progressPB.Value = (x / fileCount) * 100;
  }
  
  // compare by file name
  int compareFiles(FileSystemInfo a, FileSystemInfo b)
  {
      // return a.LastWriteTime.CompareTo(b.LastWriteTime);
      return a.Name.CompareTo(b.Name);
  }
  </code></pre>