在 WEH 8.1 中创建可通过 USB 连接从 pc windows 资源管理器访问的文件的最佳方法是什么

What is the best way to create a file in WEH 8.1 that's accessible from pc windows explorer via usb connection

我有一个 Windows Mobile 6.5 应用程序,它没有任何限制。我生成文件并将其放在支架上,连接到 pc,然后可以从 Windows Explorer.

复制

我需要能够在 Windows Phone 8.1 中做同样的事情,生成一个文本或 csv 文件,应该可以在任何文件夹中访问,最好是 Documents 文件夹,可以将其复制过来通过 Windows Explorer.

到电脑

我一直在尝试不同的方法,但其中 none 行得通。

文件夹选取器:(抛出不支持错误)

Windows.Storage.Pickers.FolderPicker picker = new Windows.Storage.Pickers.FolderPicker();
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads;
StorageFolder folder = await picker.PickSingleFolderAsync();

外部存储:(访问被拒绝错误)

StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
StorageFolder sdCard = (await externalDevices.GetFoldersAsync()).FirstOrDefault();

文档:(访问被拒绝错误)

StorageFolder folder = KnownFolders.DocumentsLibrary;

我让它工作了,至少在 MusicLibrary 文件夹上。

First, go to Project Properties -> Application -> Package Manifest -> Capabilities (tab) -> check Music Library

public static async Task<bool> WriteFile(string data)
{
        StorageFolder mfolder = KnownFolders.MusicLibrary;
        StorageFolder folder = await mfolder.CreateFolderAsync("MyFolder", CreationCollisionOption.OpenIfExists);
        StorageFile file = await folder.CreateFileAsync("log.txt", CreationCollisionOption.ReplaceExisting);
        await Windows.Storage.FileIO.WriteTextAsync(file, data);
        return true;
}