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