public static FileShareAuthenticationContext BeginFileShareAuthentication(string remoteUnc, string userName, string password) { string error = PinvokeWindowsNetworking.connectToRemote(remoteUnc, userName, password); if (!string.IsNullOrEmpty(error)) { throw new Exception("Error calling PinvokeWindowsNetworking.connectToRemote: " + error); } return(new FileShareAuthenticationContext(remoteUnc, userName, password)); }
public void Dispose() { if (_active) { var error = PinvokeWindowsNetworking.disconnectRemote(_remoteUnc); if (!string.IsNullOrEmpty(error)) { throw new Exception("PinvokeWindowsNetworking.disconnectRemote failed: " + error); } _active = false; } }