/// <summary> /// Creates an instance of a mapped network drive. /// </summary> /// <param name="env">Remote environment.</param> /// <param name="info">Mapped network drive info.</param> public MappedNetworkDrive(string ipAddress, MappedNetworkDriveInfo info) { _ipAddress = ipAddress; _info = info; if (_info.Auto) { MapNetworkDrive(); } }
private bool DoActionInGuest(string guestPath, Func<string,bool> action) { string fullGuestPath = Path.GetFullPath(guestPath); string guestRootPath = Path.GetPathRoot(fullGuestPath); var mappedNetworkDriveInfo = new MappedNetworkDriveInfo(guestRootPath); mappedNetworkDriveInfo.Username = UserName; mappedNetworkDriveInfo.Password = Password; mappedNetworkDriveInfo.Auto = false; OsTestLogger.WriteLine(string.Format(" Mapping 'Remote:{0}' as '{1}'", mappedNetworkDriveInfo.RemotePath, UserName)); using (var mappedNetworkDrive = new MappedNetworkDrive(this.IpAddress, mappedNetworkDriveInfo)) { string guestNetworkPath = mappedNetworkDrive.GuestPathToNetworkPath(fullGuestPath); string guestNetworkRootPath = mappedNetworkDrive.GuestPathToNetworkPath(guestRootPath); OsTestLogger.WriteLine(string.Format(" Resolving 'Remote:{0}'", guestNetworkRootPath)); mappedNetworkDrive.MapNetworkDrive(); return action(guestNetworkPath); } }