我有一个应用程序Windows Phone 8.1 Silverlight,我使用FileSavePicker。但我找不到保存MemoryString的示例。这是我在PickSaveFileAndContinue()之后的代码; 谢谢你的帮助!
public async void ContinueFileOpenPicker(FileSavePickerContinuationEventArgs args)
{
if ((args.ContinuationData["Operation"] as string) == "UpdateProfilePicture" && args.File != null)
{
var file = args.File;
using (IRandomAccessStream tileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
//GiveMyPhoto() is a method who return my MemoryStream
(App.Current as App).FilePickerContinuationArgs = null;
}
}
}
答案 0 :(得分:2)
您的var file
实际上是StorageFile file
。 Windows.Storage.FileIO
命名空间可以满足您的所有需求。
实施例
MemoryStream stream = GiveMyPhoto();
await Windows.Storage.FileIO.WriteBufferAsync(file, stream.GetWindowsRuntimeBuffer(0,(int)stream.Length));