Access folder created inside project RRS feed

  • Question

  • I tried to use this

     var mainfolder = await StorageFolder.GetFolderFromPathAsync("ms-appx:///books/" + filename);

    books is the folder created in my project,it is at the same root as common and assets folder.

    But I got an error

    An exception of type 'System.Exception' occurred in mscorlib.dll but was not handled in user code
    WinRT information: The specified path (ms-appx:///books/1234567891012) contains one or more invalid characters.
    What is wrong with my code?the folder does exist under books folder
    Wednesday, April 17, 2013 2:21 PM


  • If the intention is to read a file, you can use:

    var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///books/filename.txt"));
    Note that the file must be suffixed (in this example with .txt). Accessing a suffixless file creates an exception.
    • Proposed as answer by Jesse Jiang Monday, April 22, 2013 6:45 AM
    • Marked as answer by Jesse Jiang Tuesday, April 23, 2013 6:17 AM
    Wednesday, April 17, 2013 2:41 PM

All replies