title: c# UNC path stills works when using NetUseDel
body: <p>I am using NetUse to create a connection to a UNC path to enumerate the directories. Upon, NetUseDelete, I need unauthorized exceptions to start happening immediately. Currently, it seems that NetUseDelete's effect is deleted, at least in .NET. The following unit test demonstrates what SHOULD happen.</p>
  
  <pre><code>// delete every net connection to ensure clean test
  var share = @"\\234.234.234.234\share";
  var username = "user...";
  var password = "password...";
  
  // to begin with, access should be denied
  Assert.Throws&lt;UnauthorizedAccessException&gt;(() =&gt; new DirectoryInfo(share).GetDirectories());
  
  // the using statement calls NetUseDel when the connection is disposed off.
  using (var connection = _networkBrowserService.GetUncConnection())
  {
      // calls NetUse
      if (connection.NetUseWithCredentials(share, username, null, password))
      {
          // succeeded!
          // this should not throw an error!
          new DirectoryInfo(share).GetDirectories();
      }
      else
      {
          Assert.Fail("Couldn't authenticate username/password");
      }
  }
  
  // now that we disposed our connection, we should get access denied again
  Assert.Throws&lt;UnauthorizedAccessException&gt;(() =&gt; new DirectoryInfo(share).GetDirectories());
  </code></pre>
  
  <p>That last Assert fails because GetDirectories() doesn't thrown error.</p>
  
  <p>If I set a breakpoint and wait a bit, GetDirectories() will throw an exception as expected.</p>
  
  <p>I have checked "net use" and there are no connections established when GetDirectories() pass, which is incorrect. GetDirectories() should fail if "net use" shows no connections.</p>
  
  <p>Any ideas? Is there some cache in .NET that I can clear?</p>