在对metro环境下对文件压缩测试的时候。下面的代码出现The specified buffer index is not within the buffer capacity.错误。
其中 fileToCompress 为 StorageFile。
byte[] buffer = WindowsRuntimeBufferExtensions.ToArray(await FileIO.ReadBufferAsync(fileToCompress));
解决办法:找到fileToCompress对应的文件(可以通过fileToCompress.path得到文件路径),我这是1.txt,在里面写点东西。问题解决。
我觉得可能是1.txt为0Kb的原因。