-1

查找此错误并告诉 我 您的意见以解决此问题任何人有任何想法如何在他们之间建立联系或有任何演示请告诉我

4

1 回答 1

0

我不确定我是否理解您的问题。这是我在 WinRT/Win10 商店应用程序中选择文件并写入文件的代码。

private async void SaveFileExecute()
{
    var fileNameTab = FileName.Split('.');
    var extension = fileNameTab[1];
    var fileName = fileNameTab[0];
    var savePicker = new FileSavePicker
    {
        SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
        SuggestedFileName = fileName
    };

    savePicker.FileTypeChoices.Add(extension, new List<string> { "." + extension });

    var saveFile = await savePicker.PickSaveFileAsync();

    if (saveFile != null)
    {
        using (var fileStream = await saveFile.OpenAsync(FileAccessMode.ReadWrite))
        {
            using (var outputStream = fileStream.GetOutputStreamAt(0))
            {
                using (var dataWriter = new DataWriter(outputStream))
                {
                    dataWriter.WriteBytes(SelectedFile.Data);
                    await dataWriter.StoreAsync();
                    dataWriter.DetachStream();
                }

                await outputStream.FlushAsync();
            }
        }
    }
}
于 2015-08-26T15:39:23.207 回答