private void ExtendFile(long numberOfAdditionalBytes) { long footerOffset = m_file.Size - VHDFooter.Length; m_file.Extend(numberOfAdditionalBytes); byte[] footerBytes = m_vhdFooter.GetBytes(); if (m_vhdFooter.DiskType != VirtualHardDiskType.Fixed) { m_file.WriteSectors(0, footerBytes); } m_file.WriteSectors((footerOffset + numberOfAdditionalBytes) / BytesPerDiskSector, footerBytes); }
public override void Extend(long numberOfAdditionalBytes) { if (numberOfAdditionalBytes % this.BytesPerSector > 0) { throw new ArgumentException("numberOfAdditionalBytes must be a multiple of BytesPerSector"); } if (m_vhdFooter.DiskType == VirtualHardDiskType.Fixed) { long length = this.Size; // does not include the footer m_file.Extend(numberOfAdditionalBytes); m_vhdFooter.CurrentSize += (ulong)numberOfAdditionalBytes; byte[] footerBytes = m_vhdFooter.GetBytes(); m_file.WriteSectors((length + numberOfAdditionalBytes) / this.BytesPerSector, footerBytes); } else { throw new NotImplementedException(); } }