Search code examples
javascriptwindows-phone-8windows-runtimewindows-store-appswinjs

How to acces a file in App package for Windows store app


I am trying to access a particular file from my app installed package but im gettin Javascript type mismatch error. what am i doing wrong. Please tell me a good way to access any file from my installed package.

Windows.Storage.StorageFile.getFileFromApplicationUriAsync("ms-appx://PackageName/images/appicon.png").done(
function (file) {

    // Process file
}

);


Solution

  • Need to create an URI from the string first.

    var uri = new Windows.Foundation.Uri("ms-appx:///datafile.xml")
    Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done()
    

    MSDN Link: StorageFile.GetFileFromApplicationUriAsync