UnauthorizedAccessException during storageFolder.CreateFileAsync

前端 未结 2 425
陌清茗
陌清茗 2021-01-26 16:19

I have the following piece of code

    // Point to c:\\users\\yancheng\\documents\\visual studio 2012\\Projects\\App5\\App5\\bin\\x86\\Debug\\AppX
    StorageFol         


        
2条回答
  •  暖寄归人
    2021-01-26 16:52

    From your comments above, I'm assuming that you've checked the "Documents Library" capability in the package.appxmanifest.

    Check out the remarks in the documentation for StorageFolder.CreateFileAsync. It says: "If you try to create a file in a virtual folder like a library or a file group, this method may fail." Then in the Example section, it shows a different way to create a new file in the Documents library using Windows.Storage.KnownFolders.documentsLibrary.createFileAsync(). Can you try that and see if it works?

提交回复
热议问题