title: Connect to server and get directories using WinForms C#
body: <p>I need some help, I want to build a windowsForm app which allows me connect to remote server with credentials and get the shared directories.</p>
  
  <p>Already try this, but it throws me an unauthorized access exception when I use credentials different from those of my PC.</p>
  
  <pre><code>NetworkCredential netCredential = new NetworkCredential(user, password, domain);
  CredentialCache netCache = new CredentialCache();
  netCache.Add(@"\\" + server, port, "Basic", netCredential);
  string[] theFolders = System.IO.Directory.GetDirectories(@"\\" + server);
  </code></pre>
  
  <p>Thanks everyone for the help!</p>