/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] GetContent()
        {
            FatVolumeBootRecord vbr = VolumeBootRecord.Get(this.Volume) as FatVolumeBootRecord;

            int RootDirSectors = ((vbr.BPB_RootEntryCount * 32) + (vbr.BytesPerSector - 1)) / vbr.BytesPerSector;

            uint FatSize = 0;

            if (vbr.BPB_FatSize16 != 0)
            {
                FatSize = vbr.BPB_FatSize16;
            }
            else
            {
                FatSize = vbr.BPB_FatSize32;
            }

            uint FirstDataSector = (uint)(vbr.ReservedSectors + (vbr.BPB_NumberOfFATs * FatSize) + RootDirSectors);

            uint FirstSectorofCluster = ((this.FirstCluster - 2) * vbr.SectorsPerCluster) + FirstDataSector;

            byte[] bytes = DD.Get(this.Volume, (long)FirstSectorofCluster * (long)vbr.BytesPerSector, vbr.BytesPerSector, 1);

            if (this.Directory)
            {
                return(bytes);
            }
            else
            {
                if (this.FileSize <= bytes.Length)
                {
                    return(Helper.GetSubArray(bytes, 0, this.FileSize));
                }
                else
                {
                    // Need to do more...
                    return(bytes);
                }
            }
        }
        public static FileAllocationTableEntry Get(string volume, int sector)
        {
            VolumeBootRecord vbr = FileSystems.VolumeBootRecord.Get(volume) as VolumeBootRecord;
            byte[] bytes = FileAllocationTable.GetBytes(volume, vbr);

            int endSector = 0;

            switch (vbr.FileSystemType)
            {
                case "FAT12":
                    endSector = parseFat12(bytes, sector);
                    break;
                case "FAT16":
                    endSector = parseFat16(bytes, sector);
                    break;
                case "FAT32":
                    endSector = parseFat32(bytes, sector);
                    break;
            }

            return new FileAllocationTableEntry(sector, endSector);
        }
 internal static byte[] GetBytes(string volume, VolumeBootRecord vbr)
 {
     ulong DirectoryEntryOffset = (ulong)(vbr.ReservedSectors * vbr.BytesPerSector);
     return Helper.readDrive(volume, DirectoryEntryOffset, (vbr.SectorsPerFat * vbr.BytesPerSector));
 }
 public static byte[] GetBytes(string volume)
 {
     return(GetBytes(volume, VolumeBootRecord.Get(volume) as FatVolumeBootRecord));
 }
 public static byte[] GetBytes(string volume)
 {
     Fat.VolumeBootRecord vbr = VolumeBootRecord.Get(volume) as Fat.VolumeBootRecord;
     return(Helper.readDrive(volume, (uint)vbr.LocationOfFsInformationSector * vbr.BytesPerSector, vbr.BytesPerSector));
 }
Exemple #6
0
        public static FileSystemInformation Get(string volume)
        {
            FatVolumeBootRecord vbr = VolumeBootRecord.Get(volume) as FatVolumeBootRecord;

            return(new FileSystemInformation(DD.Get(volume, (vbr.BytesPerSector * vbr.BPB_FileSytemInfo), vbr.BytesPerSector, 1)));
        }