locked
How do I access a file that is nested inside other folders

    Question

  • Im trying to access 'file.txt' thats in my local data directory at "myfolder/myfolder2/myfolder3/myfolder4"

    Using this code I get a error "WinRTError: The parameter is incorrect." from the get folder call. Is this not a valid parameter?

    The documentation states the param is to be a string that is "The name (or path relative to the current folder) of the sub-folder to retrieve."

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefolder.getfolderasync

    What am I doing wrong? Thanks!


    var localFolder = Windows.Storage.ApplicationData.current.localFolder localFolder.getFolderAsync("myfolder/myfolder2/myfolder3/myfolder4") .then(function (folder) { folder.getFileAsync('file.txt').then(function (sampleFile) { var f = Windows.Storage.FileIO.readTextAsync(sampleFile); console.dir(f); return f; }, function (e) { console.log(e) }).done(function (d) { console.dir(d) }) }, function (e) { console.log(e) })





    • Edited by tkmoney1 Tuesday, April 30, 2013 5:23 PM
    Tuesday, April 30, 2013 5:04 PM

Answers

  • Use this :

    localFolder.getFolderAsync("myfolder\\myfolder2\\myfolder3\\myfolder4")
    

    - Giirja
    • Marked as answer by tkmoney1 Tuesday, April 30, 2013 6:54 PM
    Tuesday, April 30, 2013 6:49 PM

All replies

  • Use this :

    localFolder.getFolderAsync("myfolder\\myfolder2\\myfolder3\\myfolder4")
    

    - Giirja
    • Marked as answer by tkmoney1 Tuesday, April 30, 2013 6:54 PM
    Tuesday, April 30, 2013 6:49 PM
  • Thanks! Why does this work?
    Tuesday, April 30, 2013 6:54 PM