我正在尝试将大 UInt16 数组保存到文件中。positionCnt 大约 50000,stationCnt 大约 2500。直接保存,不使用 GZipStream,文件大约 250MB,可以通过外部 zip 程序压缩到 19MB。使用以下代码,文件为 507MB。我做错了什么?
GZipStream cmp = new GZipStream(File.Open(cacheFileName, FileMode.Create), CompressionMode.Compress);
BinaryWriter fs = new BinaryWriter(cmp);
fs.Write((Int32)(positionCnt * stationCnt));
for (int p = 0; p < positionCnt; p++)
{
for (int s = 0; s < stationCnt; s++)
{
fs.Write(BoundData[p, s]);
}
}
fs.Close();