本文整理汇总了C#中Partition.CleanCaches方法的典型用法代码示例。如果您正苦于以下问题:C# Partition.CleanCaches方法的具体用法?C# Partition.CleanCaches怎么用?C# Partition.CleanCaches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Partition
的用法示例。
在下文中一共展示了Partition.CleanCaches方法的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));
}
#if FATFS_TRACE
BasicConsole.WriteLine("FAT recognised. Setting up empty FAT table...");
try
{
#endif
//Mark all clusters as empty
fs.ThePartition.WriteBlock(fs.ReservedSectorCount, FATSectorCount, null);
#if FATFS_TRACE
}
catch
{
BasicConsole.WriteLine("Failed to clear potentially pre-existing FAT table! File system may not function as expected.");
FOS_System.GC.Cleanup();
FOS_System.GC.Cleanup();
}
BasicConsole.WriteLine("Marking root directory cluster as used...");
#endif
//Mark root cluster as being 1 cluster in size.
fs.SetFATEntryAndSave(2, GetFATEntryEOFValue(FATTypeEnum.FAT32));
#if FATFS_TRACE
BasicConsole.WriteLine("Done. Clearing the root directory...");
#endif
//Empty the root directory (in case of junk data)
fs.WriteCluster(2, null);
#if FATFS_TRACE
BasicConsole.WriteLine("Format complete.");
#endif
fs.thePartition.CleanCaches();
}