【发布时间】:2013-10-30 14:31:52
【问题描述】:
我搜索并找到了这个,但它不适用于 Windows Phone 8,并且仅适用于 Windows 应用商店应用:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.fileio.writebytesasync
我如何在 WP8 中做到这一点?
【问题讨论】:
标签: windows-phone-8 bytearray storagefile
我搜索并找到了这个,但它不适用于 Windows Phone 8,并且仅适用于 Windows 应用商店应用:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.fileio.writebytesasync
我如何在 WP8 中做到这一点?
【问题讨论】:
标签: windows-phone-8 bytearray storagefile
您可以使用二进制编写器:
byte[] buffer;
using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream FS = new IsolatedStorageFileStream(fileName, FileMode.Create, ISF))
{
using (BinaryWriter BW = new BinaryWriter(FS))
{
BW.Write(buffer, 0, buffer.Lenght);
}
}
}
或者像@KooKiz 所说的让它更简单:
using (IsolatedStorageFileStream FS = new IsolatedStorageFileStream(fileName, FileMode.Create, ISF))
{
FS.Write(buffer, 0, buffer.Lenght);
}
【讨论】:
fs.Write(buffer, 0, buffer.Length);