当前位置: 首页>>代码示例>>C#>>正文


C# Partition.WriteBlock方法代码示例

本文整理汇总了C#中Partition.WriteBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Partition.WriteBlock方法的具体用法?C# Partition.WriteBlock怎么用?C# Partition.WriteBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Partition的用法示例。


在下文中一共展示了Partition.WriteBlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FormatPartitionAsFAT32


//.........这里部分代码省略.........
            uint bytesPer2FAT = (uint)Math.Divide((4 * (ulong)dataClusters * bytesPerCluster), (bytesPerCluster + 8)); //Calculation rounds down
#if FATFS_TRACE
            BasicConsole.WriteLine(((FOS_System.String)"bytesPer2FAT: ") + bytesPer2FAT);
#endif
            uint FATSectorCount = bytesPer2FAT / bytesPerSector;
#if FATFS_TRACE
            BasicConsole.WriteLine(((FOS_System.String)"FATSectorCount: ") + FATSectorCount);
#endif
            newBPBData[36] = (byte)(FATSectorCount);
            newBPBData[37] = (byte)(FATSectorCount >> 8);
            newBPBData[38] = (byte)(FATSectorCount >> 16);
            newBPBData[39] = (byte)(FATSectorCount >> 24);
            
#if FATFS_TRACE
            BasicConsole.WriteLine(((FOS_System.String)"totalSectors: ") + totalSectors +
                                                       ", reservedSectors: " + reservedSectors +
                                                       ", sectorsPerCluster: " + sectorsPerCluster +
                                                       ", bytesPerSector: " + bytesPerSector +
                                                       ", bytesPerCluster: " + bytesPerCluster +
                                                       ", dataClusters: " + dataClusters +
                                                       ", bytesPer2FAT: " + bytesPer2FAT +
                                                       ", FATSectorCount: " + FATSectorCount);
            BasicConsole.DelayOutput(10);
#endif

            //Root cluster (number/index - min value is 2)
            newBPBData[44] = 0x02;
            
#if FATFS_TRACE
            BasicConsole.WriteLine("Writing new BPB...");
            BasicConsole.DelayOutput(1);
#endif

            thePartition.WriteBlock(0UL, 1U, newBPBData);
            
#if FATFS_TRACE
            BasicConsole.WriteLine("Written new BPB. Attempting to load new file system...");
#endif

            thePartition.CleanCaches();

            FATFileSystem fs = new FATFileSystem(thePartition);
            if (!fs.IsValid)
            {
#if FATFS_TRACE
                BasicConsole.WriteLine("Failed to format properly. Scrubbing new BPB...");
#endif
                thePartition.WriteBlock(0UL, 1U, null);
#if FATFS_TRACE
                BasicConsole.WriteLine("Scrub done.");
#endif

                ExceptionMethods.Throw(new FOS_System.Exception("Failed to format properly! FATFileSystem did not recognise system as valid."));
            }
            else if (fs.FATType != FATTypeEnum.FAT32)
            {
#if FATFS_TRACE
                BasicConsole.WriteLine("Failed to format properly. Scrubbing new BPB...");
#endif
                byte[] scrubBPB = thePartition.TheDiskDevice.NewBlockArray(1);
                thePartition.WriteBlock(0UL, 1U, scrubBPB);
#if FATFS_TRACE
                BasicConsole.WriteLine("Scrub done.");
#endif

                ExceptionMethods.Throw(new FOS_System.Exception(((FOS_System.String)"Failed to format properly! FATFileSystem recognised incorrect FAT type. Type recognised: ") + (uint)fs.FATType));
开发者ID:rmhasan,项目名称:FlingOS,代码行数:67,代码来源:FATFileSystem.cs


注:本文中的Partition.WriteBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。