locked
How do i send user credentials when using GetFolderFromPathAsync to access a network drive ? RRS feed

  • Question

  • Im getting an UnauthorizedAccessException here is my code ,i just want to know how to authenticate the user 

      StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(@"\\**********");
                IReadOnlyList<IStorageItem> list = await storageFolder.GetItemsAsync();


    19karabo91

    Monday, January 6, 2014 1:15 PM

Answers

  • Since you're accessing a known network folder, the best thing to do in this case is map a network drive and access it via the mapped drive.  There's no way to send credentials otherwise.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by 19karabo91 Tuesday, January 7, 2014 6:21 AM
    Monday, January 6, 2014 4:22 PM
    Moderator
  • Thanks I've manage to pass through the authentication process ,after the 2nd line in the code i get a list of available folders in the drive ,how do i iterate through it and get the child elements so that i can display them on my metro app ?

    19karabo91

    • Marked as answer by 19karabo91 Tuesday, January 7, 2014 6:21 AM
    Tuesday, January 7, 2014 6:20 AM

All replies

  • Your app cannot read arbitrary locations without explicit user permission.

    With appropriate capabilities it can read declared file types from UNC paths. See Accessing additional locations

    The users credentials will be passed automatically. I don't believe there is a way to provide custom credentials.

    Monday, January 6, 2014 3:12 PM
    Moderator
  • Since you're accessing a known network folder, the best thing to do in this case is map a network drive and access it via the mapped drive.  There's no way to send credentials otherwise.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by 19karabo91 Tuesday, January 7, 2014 6:21 AM
    Monday, January 6, 2014 4:22 PM
    Moderator
  • Thanks I've manage to pass through the authentication process ,after the 2nd line in the code i get a list of available folders in the drive ,how do i iterate through it and get the child elements so that i can display them on my metro app ?

    19karabo91

    • Marked as answer by 19karabo91 Tuesday, January 7, 2014 6:21 AM
    Tuesday, January 7, 2014 6:20 AM