The specified buffer index is not within the buffer capacity.

在对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的原因。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章