title: How can I access a mapped network drive with System.IO.DirectoryInfo?
body: <p>I need to create a directory on a mapped network drive. I am using a code:</p>
  
  <pre><code>DirectoryInfo targetDirectory = new DirectoryInfo(path);
  if (targetDirectory != null)
  {
      targetDirectory.Create();
  }
  </code></pre>
  
  <p>If I specify the path like "\\\\ServerName\\Directory", it all goes OK. If I map the "\\ServerName\Directory" as, say drive Z:, and specify the path like "Z:\\", it fails.</p>
  
  <p>After the creating the targetDirectory object, VS shows (in the debug mode) that targetDirectory.Exists = false, and trying to do targetDirectory.Create() throws an exception:</p>
  
  <pre><code>System.IO.DirectoryNotFoundException: "Could not find a part of the path 'Z:\'."
  </code></pre>
  
  <p>However, the same code works well with local directories, e.g. C:.</p>
  
  <p>The application is a Windows service (WinXP Pro, SP2, .NET 2) running under the same account as the user that mapped the drive. Qwinsta replies that the user's session is the session 0, so it is the same session as the service's.</p>