title: How to order list of files by file name with number?
body: <p>I have a bunch of files in a directory that I am trying to get based off their type. Once I have them I would like to order them by file name (there is a number in them and I would like to order them that way)</p>
  
  <p>My files returned are:</p>
  
  <pre><code>file-1.txt
  file-2.txt
  ...
  file-10.txt
  file-11.txt
  ...
  file-20.txt
  </code></pre>
  
  <p>But the order I get them in looks something more closely to this:</p>
  
  <pre><code>file-1.txt
  file-10.txt
  file-11.txt
  ...
  file-2.txt
  file-20.txt
  </code></pre>
  
  <p>Right now I am using <code>Directory.GetFiles()</code> and attempting to using the <code>linq OrderBy</code> property. However, I am failing pretty badly with what I would need to do to order my list of files like the first list above.</p>
  
  <p><code>Directory.GetFiles()</code> seems to be returning a list of strings so I am unable to get the list of file properties such as <code>filename</code> or <code>name</code>.</p>
  
  <p>Here is my code currently:</p>
  
  <pre><code>documentPages = Directory.GetFiles(documentPath, "*.txt").OrderBy(Function(p) p).ToList()
  </code></pre>
  
  <p>Would anyone have any ideas?</p>