private void doNetUse(
            string networkName,
            string userName,
            string password,
            ZlpNetworkConnectionResourceScope scope,
            ZlpNetworkConnectionResourceType resourceType,
            ZlpNetworkConnectionResourceDisplayType displayType,
            ZlpNetworkConnectionResourceUsage usage,
            ZlpNetworkConnectionFlags flags)
        {
            var netResource = new NetResource
            {
                Scope        = scope,
                ResourceType = resourceType,
                DisplayType  = displayType,
                RemoteName   = networkName,
                Usage        = usage
            };

            var result = WNetAddConnection2(
                netResource,
                password,
                userName,
                flags);

            if (result != 0)
            {
                throw new IOException(string.Format(Resources.ErrorConnectingToRemoteShare, networkName, result),
                                      result);
            }

            _networkName = networkName;
        }
 public void Connect(
     string networkName,
     string userName,
     string password,
     ZlpNetworkConnectionResourceScope scope             = ZlpNetworkConnectionResourceScope.GlobalNetwork,
     ZlpNetworkConnectionResourceType resourceType       = ZlpNetworkConnectionResourceType.Disk,
     ZlpNetworkConnectionResourceDisplayType displayType = ZlpNetworkConnectionResourceDisplayType.Share,
     ZlpNetworkConnectionResourceUsage usage             = ZlpNetworkConnectionResourceUsage.None,
     ZlpNetworkConnectionFlags flags = ZlpNetworkConnectionFlags.None)
 {
     doNetUse(networkName, userName, password, scope, resourceType, displayType, usage, flags);
 }