C#如何在文件保存选择器之后保存MemoryStream

C#如何在文件保存选择器之后保存MemoryStream,c#,silverlight,windows-phone-8.1,C#,Silverlight,Windows Phone 8.1,我有一个应用程序Windows Phone 8.1 Silverlight,我使用FileSavePicker。但是我没有找到一个样本来保存我的记忆串。这是我在PickSaveFileAndContinue()之后的代码; 谢谢你的帮助 public async void ContinueFileOpenPicker(FileSavePickerContinuationEventArgs args) { if ((args.ContinuationData["Op

我有一个应用程序Windows Phone 8.1 Silverlight,我使用FileSavePicker。但是我没有找到一个样本来保存我的记忆串。这是我在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;
            }
        }
    }

您的
var文件
实际上是一个
StorageFile文件
Windows.Storage.FileIO
名称空间包含您所需的所有内容

范例

MemoryStream stream = GiveMyPhoto();

await Windows.Storage.FileIO.WriteBufferAsync(file, stream.GetWindowsRuntimeBuffer(0,(int)stream.Length));

从我所读到的来看,使用GetWindowsRuntimeBuffer是不安全的。最好将数据保存为
字节[]
<代码>等待Windows.Storage.FileIO.WriteByteBSASYC(字节)