public async Task Dismount(AppxVolume volume, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = default) { using var session = await PowerShellSession.CreateForAppxModule().ConfigureAwait(false); using var command = session.AddCommand("Dismount-AppxVolume"); command.AddParameter("Volume", volume.Name); await session.InvokeAsync(progress).ConfigureAwait(false); }
public Task Mount(AppxVolume volume, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = default) { var proxyObject = new MountDto { Name = volume.Name }; return(this.client.Invoke(proxyObject, cancellationToken, progress)); }
public Task SetDefault(AppxVolume volume, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = default) { var proxyObject = new SetDefaultDto { DrivePath = volume.PackageStorePath }; return(this.client.Invoke(proxyObject, cancellationToken, progress)); }
public async Task <AppxVolume> GetVolumeForPath(string path, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = default) { var di = new DirectoryInfo(path); if (!di.Exists) { throw new DirectoryNotFoundException("Directory was not found."); } if (di.Attributes.HasFlag(FileAttributes.ReparsePoint)) { var target = GetSymbolicLinkTarget(di); path = target; } using var session = await PowerShellSession.CreateForAppxModule().ConfigureAwait(false); using var command = session.AddCommand("Get-AppPackageVolume"); command.AddParameter("Path", path); var result = await session.InvokeAsync(progress).ConfigureAwait(false); var item = result.FirstOrDefault(); if (item == null) { return(null); } var name = (string)item.Properties.FirstOrDefault(p => p.Name == "Name")?.Value; var packageStorePath = (string)item.Properties.FirstOrDefault(p => p.Name == "PackageStorePath")?.Value; var letter = packageStorePath != null && packageStorePath.Length > 2 && packageStorePath[1] == ':' ? packageStorePath.Substring(0, 1) + ":\\" : null; var appxVolume = new AppxVolume { Name = name, PackageStorePath = packageStorePath }; if (letter == null) { return(appxVolume); } var drive = DriveInfo.GetDrives().FirstOrDefault(d => d.RootDirectory.FullName.StartsWith(letter, StringComparison.OrdinalIgnoreCase)); if (drive == null) { return(appxVolume); } appxVolume.IsDriveReady = drive.IsReady; appxVolume.DiskLabel = drive.VolumeLabel; appxVolume.Capacity = drive.TotalSize; appxVolume.AvailableFreeSpace = drive.AvailableFreeSpace; return(appxVolume); }
public Task MovePackageToVolume(AppxVolume volume, AppxPackage package, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = default) { if (volume == null) { throw new ArgumentNullException(nameof(volume)); } if (package == null) { throw new ArgumentNullException(nameof(package)); } return(this.MovePackageToVolume(volume.Name, package.FullName, cancellationToken, progress)); }
public MovePackageToVolumeDto(AppxPackage package, AppxVolume volume) { if (package == null) { throw new ArgumentNullException(nameof(package)); } if (volume == null) { throw new ArgumentNullException(nameof(volume)); } this.PackageFullName = package.FullName; this.VolumePackagePath = volume.PackageStorePath; }
public async Task <AppxVolume> GetDefault(CancellationToken cancellationToken = default, IProgress <ProgressData> progress = default) { using var session = await PowerShellSession.CreateForAppxModule().ConfigureAwait(false); using var command = session.AddCommand("Get-AppxDefaultVolume"); var result = await session.InvokeAsync(progress).ConfigureAwait(false); var item = result.FirstOrDefault(); if (item == null) { return(null); } var baseType = item.BaseObject.GetType(); var name = (string)baseType.GetProperty("Name")?.GetValue(item.BaseObject); var packageStorePath = (string)baseType.GetProperty("PackageStorePath")?.GetValue(item.BaseObject); var letter = packageStorePath != null && packageStorePath.Length > 2 && packageStorePath[1] == ':' ? packageStorePath.Substring(0, 1) + ":\\" : null; var appxVolume = new AppxVolume { Name = name, PackageStorePath = packageStorePath }; if (letter != null) { var drive = DriveInfo.GetDrives().First(d => d.RootDirectory.FullName.StartsWith(letter, StringComparison.OrdinalIgnoreCase)); if (drive != null) { appxVolume.IsDriveReady = drive.IsReady; appxVolume.DiskLabel = drive.VolumeLabel; appxVolume.Capacity = drive.TotalSize; appxVolume.AvailableFreeSpace = drive.AvailableFreeSpace; } } return(appxVolume); }
public DismountDto(AppxVolume volume) : this(volume.Name) { }
public VolumeViewModel(AppxVolume model) { this.Model = model; }
public VolumeCandidateViewModel(AppxVolume model) { this.Model = model; }
public SetDefaultDto(AppxVolume volume) : this(volume.PackageStorePath) { }
public DeleteDto(AppxVolume volume) : this(volume.Name) { }