我有 5MB 字节 [],我以 2k 的块写入磁盘。为了获得 2k (c_writeSizeInBytes) 的卡盘,我这样做:
int numberOfIterations = bytes.Length / c_writeSizeInBytes;
for (int i = 0; i < numberOfIterations; i++)
{
bool nearEnd = bytes.Length - i == c_writeSizeInBytes;
byte[] buffer = nearEnd ? bytes.Skip(i * c_writeSizeInBytes).ToArray() : bytes.Skip(i * c_writeSizeInBytes).Take(c_writeSizeInBytes).ToArray();
binaryWriter.Write(buffer, 0, c_writeSizeInBytes);
}
2MB 后 5MB 文件的性能非常慢。有什么办法可以优化吗?
谢谢