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

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