我在 a 中有一个文件byte[]
,我需要删除0x1000
每个偏移量的字节x
(我有一个偏移量列表)。我有一些代码可以做到这一点,但我想知道是否有更好的方法来做到这一点;
private byte[] RemoveHashBlocks(byte[] fileArray, STFSExplorer stfs)
{
long startOffset = StartingOffset;
long endOffset = StartingOffset + Size;
List<long> hashBlockOffsets = new List<long>();
foreach (xBlockEntry block in stfs._stfsBlockEntry)
if (block.IsHashBlock && (block.BlockOffset >= startOffset && block.BlockOffset <= endOffset))
hashBlockOffsets.Add(block.BlockOffset - (hashBlockOffsets.Count * 0x1000));
byte[] newFileAray = new byte[fileArray.Length - (hashBlockOffsets.Count * 0x1000)];
for (int offset = 0; offset < fileArray.Length; offset++)
if (hashBlockOffsets[0] == offset)
{
offset += 0x1000;
hashBlockOffsets.RemoveAt(0);
}
else
newFileAray[offset] = fileArray[offset];
return newFileAray;
}