public async Task MountAsync( [NotNull] string path, ImageMountOptions options ) => await this.MountAsync( path, options, CancellationToken.None, null);
public static extern void DismMountImage( [NotNull] string imageFilePath, [NotNull] string mountPath, uint imageIndex, [CanBeNull] string imageName, DismImageIdentifier imageIdentifier, ImageMountOptions flags, [CanBeNull] SafeWaitHandle cancelEvent, [CanBeNull] DismProgressCallback progress, IntPtr userData );
public async Task MountAsync( [NotNull] string path, ImageMountOptions options, CancellationToken cancellationToken, [CanBeNull] IProgress <DismEventArgs> progress ) { if (path == null) { throw new ArgumentNullException("path"); } if (File.Exists(path)) { throw new ArgumentException("Path is a file", "path"); } if (Directory.Exists(path) && Directory.GetFileSystemEntries(path).Length != 0) { throw new ArgumentException("Path refers to a non-empty directory", "path"); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } await Task.Run(() => NativeMethods.DismMountImage( this._imagePath, path, this._imageIndex, null, DismImageIdentifier.DismImageIndex, options, cancellationToken.WaitHandle.SafeWaitHandle, (current, total, userData) => progress?.Report(new DismEventArgs(current, total)), IntPtr.Zero )); }
public void Mount( [NotNull] string path, ImageMountOptions options, [CanBeNull] IProgress <DismEventArgs> progress ) => Task.Run <Task>(async() => await this.MountAsync(path, options)).Wait();
public void Mount( [NotNull] string path, ImageMountOptions options ) => this.Mount(path, options, null);