コード例 #1
0
        public static void Main4(string[] args)
        {
            string label     = "Zap!";
            long   capacity  = 2L << 40;
            int    blockSize = 4 << 20;

            using (var diskStream = File.Create("big.vhdx"))
                using (var disk = Disk.InitializeDynamic(diskStream, Ownership.Dispose, capacity, blockSize))
                {
                    var gpt = GuidPartitionTable.Initialize(disk);
                    gpt.Create(gpt.FirstUsableSector, gpt.LastUsableSector, GuidPartitionTypes.WindowsBasicData, 0, null);
                    var  volume         = VolumeManager.GetPhysicalVolumes(disk).First();
                    uint bytesPerSector = (uint)(volume.PhysicalGeometry?.BytesPerSector ?? 512);
                    var  clusterCount   = 1 << 25;// uint.MaxValue - 16;
                    var  clusterSize    = capacity / clusterCount;
                    var  clusterBits    = (int)Math.Ceiling(Math.Log(clusterSize) / Math.Log(2));
                    if (clusterBits > 18)
                    {
                        clusterBits = 18;
                    }
                    //clusterBits = 20;
                    using (var fs = ExFatFileSystem.Format(volume, new ExFatFormatOptions {
                        SectorsPerCluster = (1u << clusterBits) / bytesPerSector
                    }, label: label))
                    { }
                }
        }
コード例 #2
0
 public static void Main2(string[] args)
 {
     File.Copy("Empty1.vhdx", "Empty.vhdx", true);
     using (var disk = new Disk("Empty.vhdx"))
     {
         //var gpt = GuidPartitionTable.Initialize(disk);
         //gpt.Create(gpt.FirstUsableSector, gpt.LastUsableSector, GuidPartitionTypes.WindowsBasicData, 0, null);
         var volume = VolumeManager.GetPhysicalVolumes(disk)[1];
         using (var fs = ExFatFileSystem.Format(volume))
             fs.CreateDirectory("a folder");
     }
     using (var disk = new Disk("Empty.vhdx"))
     {
         var volume = VolumeManager.GetPhysicalVolumes(disk)[1];
         using (var fs2 = new ExFatFileSystem(volume.Open()))
         {
             var i = fs2.GetDirectoryInfo("a folder");
             var e = fs2.GetDirectories("");
         }
     }
 }