title: SMB Directory Listing with C#
body: <p>I am trying to do a remote directory listing of an SMB web server.</p>
  
  <p>My method however doesn't work. The call to <code>DirectoryInfo()</code> complains that I can't give it a string in a URi format.</p>
  
  <p>This is what I have come up with:</p>
  
  <pre><code>string smbDirectory = @"\\SERVER\MYSHARE";
  Uri requestURI = new Uri(smbDirectory);
  List&lt;FileInfo&gt; files = this.listAllFilesInWebDirectory(requestURI);
  
  List&lt;FileInfo&gt; listAllFilesInWebDirectory(Uri smbDirectory)
  {
      string filePattern = "*";
      List&lt;FileInfo&gt; returnable = null;
      DirectoryInfo directory = new DirectoryInfo(smbDirectory.AbsoluteUri);
  
      if (directory.Exists == true)
      {
          FileInfo[] files = directory.GetFiles(filePattern);
          returnable = new List&lt;FileInfo&gt;(files);
      }
      return returnable;
  }
  </code></pre>
  
  <p>I keep getting an exception when I call <code>directory.GetFiles(filePattern)</code>.</p>