【问题标题】:How to export a file from the Assets folder to the phone's Documents folder in Windows Phone 8.1 RT?如何将文件从 Assets 文件夹导出到 Windows Phone 8.1 RT 中手机的 Documents 文件夹?
【发布时间】:2015-06-26 21:43:40
【问题描述】:

我正在尝试使用 C# 将文件从 Assets 文件夹导出到 Windows Phone 8.1 RT 中手机的 Documents 文件夹。我已启用文档库功能并能够访问文档库。但我无法复制文件。

有人吗?

【问题讨论】:

  • 另外,查看一个名为“文件”的应用,可以轻松搜索手机上的文件。

标签: c# windows-runtime windows-phone windows-phone-8.1


【解决方案1】:

我没有尝试从 Assets 复制文件,但我可以将文件写入手机的 Documents 文件夹中:

var myFolder = KnownFolders.DocumentsLibrary;
var myFile = await myFolder.CreateFileAsync("test.txt", CreationCollisionOption.OpenIfExists);
await FileIO.WriteTextAsync(myFile, "hello world");

清单中的文件类型关联是否正确?应该是这样的:

<Extension Category="windows.fileTypeAssociation">
  <FileTypeAssociation Name="txt">
    <DisplayName>txt</DisplayName>
      <SupportedFileTypes>
        <FileType>.txt</FileType>
      </SupportedFileTypes>
  </FileTypeAssociation>
</Extension>

【讨论】:

  • 我需要复制。不去创造。创作很好。 DocumentsLibrary 中没有复制选项。 ://
  • 什么样的文件?您可以从 Assets 文件夹中以 byte[] 格式读取它们,然后将它们写入 Documents 文件夹吗?
  • 这是一个 SQlite 数据库文件。尺寸可以很大。
  • 多大?我仍然会尝试将文件从资产复制到内存,然后复制到文档文件夹。看看它是否内存不足。
  • 我做到了。不得不使用 FileSavePicker。谢谢! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-02
  • 1970-01-01
相关资源
最近更新 更多