title: WNetAddConnection2 returns Error 1200 - Local name is valid
body: <p>I'm trying to connect a share (let's say \server\folder) to my local device X:</p>
  
  <pre><code>[DllImport("Mpr.dll", CharSet = CharSet.Unicode, SetLastError = true)]
          private static extern int WNetAddConnection2(
              [In] NetResource lpNetResource,
              string lpPassword,
              string lpUsername,
              int flags
          );
  
  public static bool Connect(string remoteName, string localName, bool persistent) {
              if (!IsLocalPathValid(localName)) return false;
              var r = new NetResource
              {
                  dwScope = ResourceScope.RESOURCE_GLOBALNET,
                  dwType = ResourceType.RESOURCETYPE_ANY,
                  dwDisplayType = ResourceDisplayType.RESOURCEDISPLAYTYPE_SHARE,
                  dwUsage = ResourceUsage.RESOURCEUSAGE_CONNECTABLE,
                  lpRemoteName = remoteName,
                  lpLocalName = localName
              };
              return WNetAddConnection2(r, null, null, persistent ? 1 : 0) == 0;
          }
  
  [StructLayout(LayoutKind.Sequential)]
      public class NetResource {
          public ResourceScope dwScope;
          public ResourceType dwType;
          public ResourceDisplayType dwDisplayType;
          public ResourceUsage dwUsage;
          public string lpLocalName;
          public string lpRemoteName;
          public string lpComment;
          public string lpProvider;
      }
  </code></pre>
  
  <p>When calling </p>
  
  <pre><code>Connect(@"\\server\folder", "X:", true);
  </code></pre>
  
  <p>the function just returns false - the Error says 1200 (BAD_DEVICE).
  The NetResource looks like this:</p>
  
  <pre><code>lpRemoteName = "\\\\server\\folder"; 
  lpProvider = null;
  lpLocalName = "X:";
  lpComment = null;
  dwUsage = Connectable; 
  dwType = Any; 
  dwScope = GlobalNet; 
  dwDisplayType = Share;
  </code></pre>
  
  <p>I already checked with several snippets (PInvoke) put i can't see any difference. Maybe you can solve this mystery... </p>
  
  <p><strong>EDIT1</strong></p>
  
  <p><a href="https://i.stack.imgur.com/FsNUR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FsNUR.png" alt="Variables when trying to map the drive"></a></p>