/// <summary> /// Refreshes the logical device. /// </summary> public void Refresh() { bootSector = null; data = new UInt16[0]; // Jump to FAT partition DeviceStream.Seek(partition.RelativeSector * PhysicalDevice.SectorSize, SeekOrigin.Begin); if (!partition.IsFAT) { return; } // Boot sector bootSector = (BootSector)StreamActivator.CreateInstance(typeof(BootSector), DeviceStream); DeviceStream.Seek(448, SeekOrigin.Current); // Failsafe .. be sure FAT partition table is valid if ((DeviceStream.ReadByte() != 0x55) || (DeviceStream.ReadByte() != 0xAA)) { bootSector = null; return; } // Get FAT sector BinaryReader br = new BinaryReader(DeviceStream); data = new UInt16[bootSector.NumberOfFATs * ((bootSector.SectorsPerFAT * PhysicalDevice.SectorSize) / 2)]; for (int i = 0; i < data.Length; i++) { data[i] = br.ReadUInt16(); } }