using System; using DiscUtils; using DiscUtils.Ntfs; using DiscUtils.Partitions; using DiscUtils.Streams; using DiscUtils.Vhd; using System.IO; namespace SvdCli { internal class TasteProgram { private static void Main(string[] args) { var diskSize = 5L * 1024 * 1024 * 1024; using (var fs = new FileStream(@"z:\test.img", FileMode.OpenOrCreate)) { { VirtualDisk destDisk = DiscUtils.Raw.Disk.Initialize(fs, Ownership.None, diskSize); BiosPartitionTable.Initialize(destDisk, WellKnownPartitionType.WindowsNtfs); var volMgr = new VolumeManager(destDisk); var label = "ZZZZZZ"; using (var destNtfs = NtfsFileSystem.Format(volMgr.GetLogicalVolumes()[0], label, new NtfsFormatOptions())) { destNtfs.CreateDirectory("temp"); } //commit everything to the stream before closing fs.Flush(); } } using (var fs = new FileStream(@"z:\test.img", FileMode.OpenOrCreate)) { VirtualDisk destDisk = new DiscUtils.Raw.Disk(fs, Ownership.None); var volMgr = new VolumeManager(destDisk); using var sparseStream = volMgr.GetLogicalVolumes()[0].Open(); new NtfsFileSystemChecker(sparseStream).Check(Console.Out, ReportLevels.All); } } } }