locked
[UWP]Can't Access Documents Library in Universal Windows App RRS feed

  • Question

  • Hello,

    I'm migrating from classical windows 8.1 store app to modern universal windows app. But I'm facing some issue with accessing Documents Library with the latter one. I've added documents library in the app manifest, but too can't access it.

    Any help would be greatly appreciated.

    Thanks in advance.


    Aaru


    Thursday, October 8, 2015 12:23 PM

Answers

  • Hi Amy,

    I've tried too. But can't access documents library. Anyways thanks for the suggestion, i will prefer pictures library instead.

    Regards


    Aaru

    • Proposed as answer by dns jinung Wednesday, October 21, 2015 5:32 AM
    • Marked as answer by Aaru06 Thursday, November 12, 2015 10:54 AM
    Thursday, October 15, 2015 5:19 AM

All replies

  • What exactly are you trying to do and in what way does it fail? In general using the documents library is neither recommended or permitted. It's better to let the user choose a save location. See my blog entry http://blogs.msdn.com/b/wsdevsol/archive/2013/05/09/dealing-with-documents-how-not-to-use-the-documentslibrary-capability-in-windows-store-apps.aspx If you side load the app and use the documents library capability the app gets access only to declared file types, not to everything in documents. See https://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx#special_capabilities
    • Proposed as answer by dns jinung Wednesday, October 21, 2015 5:31 AM
    Thursday, October 8, 2015 2:23 PM
  • Hi Rob,

    Thanks for the response.

    I'm not using FileOpenPicker and am just using the below code.

    StorageFolder dataFolder = await KnownFolders.DocumentsLibrary.GetFolderAsync("Data");

    Regards


    Aaru

    Friday, October 9, 2015 4:20 AM
  • Hi Aaru06,

    As @Rob Caplan [MSFT] said, in general using the documents library is neither recommended or permitted. 

    If you still want to use the DocumentsLibrary in UWP app, first please try to add the documentsLibrary capability to the Package.appxmanifest file manually as following:

    <Capabilities>
       <uap:Capability Name="documentsLibrary" />
    </Capabilities>

    After that please add File Type Associations to your app manifest that declare specific file types that your app can access:


    At last the result:

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, October 14, 2015 10:02 AM
    Owner
  • Hi Amy,

    I've tried too. But can't access documents library. Anyways thanks for the suggestion, i will prefer pictures library instead.

    Regards


    Aaru

    • Proposed as answer by dns jinung Wednesday, October 21, 2015 5:32 AM
    • Marked as answer by Aaru06 Thursday, November 12, 2015 10:54 AM
    Thursday, October 15, 2015 5:19 AM
  • Hi Aaru06,

    >>I've tried too. But can't access documents library.

    Since I do not know the exception/error that you meet, in my mind maybe you do not declare the correct file types that you want to access. Anyways, compard with the DocumentsLibrary, using the PicturesLibrary will be the better solution. :)

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, October 21, 2015 2:27 AM
    Owner
  • Hallo, 

    I've a similar issue. I've to load data from a XML file that the user could store in his Documents library.

    Even adding the documentsLibrary capability and related file type in the app manifest the app is never authorized to open the file and read data

    here some code:


          <Extensions>
            <uap:Extension Category="windows.fileTypeAssociation">
              <uap:FileTypeAssociation Name="waypoint">
                <uap:DisplayName>waypoint list</uap:DisplayName>
                <uap:SupportedFileTypes>
                  <uap:FileType>.kml</uap:FileType>
                </uap:SupportedFileTypes>
              </uap:FileTypeAssociation>
            </uap:Extension>
          </Extensions>
        </Application>
      </Applications>
      <Capabilities>
        <Capability Name="internetClient" />
        <uap:Capability Name="removableStorage" />
        <uap:Capability Name="documentsLibrary" />
        <DeviceCapability Name="location" />
      </Capabilities>
    

    and in the code:

    .....
    
            Dim picker = New Windows.Storage.Pickers.FileOpenPicker()
            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail
    
            picker.FileTypeFilter.Add(".kml")
    
            Dim file As Windows.Storage.StorageFile = Await picker.PickSingleFileAsync()
    
            If (file IsNot Nothing) Then
    
                clear_POI()
    
                Dim XMLFilePath = Path.Combine(file.Path)
                Dim kml As XElement = Nothing
    
                Try
                    Await Task.Run(Sub() kml = XElement.Load(XMLFilePath))
                Catch
                End Try
    
    .....
    
    

    Opening a .kml file in Document and sub directory always produce and exception for authorized access.

    Thanks in advance for your support. Stefano



    Monday, February 27, 2017 4:55 PM
  • Is it just me or is not crazy to deny a user access to his own documents in a UWP app???

    DogFather2

    Friday, March 1, 2019 11:02 AM
  •  ive been searching all day to be able to find somewhere sensible to store an sqlite db in a uwp app that doesnt get deleted between re-installs & upgrades from the windows store, and feel like im gunna punch my screen out - in winforms i just create a folder in the programdata and use that

    saying you have to use a folder picker is stupid - i dont want the intended audience of my app to have to choose where to store it, most of them are not too computer literate so its something that will disable the smooth flow of what i intend.



    Sunday, June 2, 2019 6:58 PM
  • WinBase, please keep your language family friendly.

    Your issue with SQLite is unrelated to this thread. If you need help with where to deploy your SQLite database then please post a new thread with your specific situation and somebody can help.

    SQLite used to impose limits on where its database could be that are tighter than what UWP allowed for files in general. I've not been tracking SQLite updates so I don't know if this has changed, and that's a subject for another thread.

    It was possible by default to create a database which remained through an app upgrade. To create one that could survive an app uninstall required writing some code to manage the alternate location. That would require user approval at some level, as apps shouldn't leave hidden or non-user files on the system when the app is removed.

    --Rob

    Monday, June 3, 2019 5:44 PM
  • DogFather,

    Users are in control of their documents, not apps. Apps cannot access arbitrary locations without the user's permission. I can install an arbitrary UWP game from the store and trust that it can't access my tax files. Tax software can request permission to those files (either explicitly or implicitly, but either way transparently).

    The specific details have changed in the several years since this thread was active, so it is easier for apps to request the user's permission to access files.

    --Rob

    Monday, June 3, 2019 5:48 PM