private string ConnectDrive(NETRESOURCE1 NetDrive, string UserName, string Password) { StringBuilder UN = new StringBuilder(UserName); StringBuilder PW = new StringBuilder(Password); return(WNetAddConnection2(NetDrive, PW, UN, 0).ToString()); }
public string CreateDrive(string LocalName, string RemoteName, string UserName, string Password) { NETRESOURCE1 NetDrive = new NETRESOURCE1(); NetDrive.LocalName = LocalName; NetDrive.RemoteName = RemoteName; NDList.Add(NetDrive); return(ConnectDrive(NetDrive, UserName, Password)); }
private static extern uint WNetAddConnection2([In] NETRESOURCE1 lpNetResource, StringBuilder lpPassword, StringBuilder lpUsername, uint dwFlags);
private string DisconnectDrive(NETRESOURCE1 NetDrive) { string LocalName = NetDrive.LocalName; return(WNetCancelConnection2(LocalName, 1, true).ToString()); }