private static async Task EnsureFormatted(Partition partition, string label, FileSystemFormat fileSystemFormat) { var volume = await partition.GetVolume(); if (volume == null) { throw new ApplicationException($"Couldn't get volume for {partition}"); } await volume.Mount(); if (Directory.EnumerateFileSystemEntries(volume.Root).Count() > 1) { throw new ApplicationException("The format operation failed. The drive shouldn't contain any file after the format"); } var sameLabel = string.Equals(volume.Label, label); var sameFileSystemFormat = Equals(volume.FileSytemFormat, fileSystemFormat); if (!sameLabel || !sameFileSystemFormat) { Log.Verbose("Same label? {Value}. Same file system format? {Value}", sameLabel, sameFileSystemFormat); throw new ApplicationException("The format operation failed"); } }