locked
copying ms-appx:///<resource to a folder in current app package

    Question

  • at runtime I am creating a folder in my package directory and in that want to copy my application asset files gets an error of type mismatch at filesource.copyAsync point.

    localFolder.createFolderAsync(

    "Cordova", Windows.Storage.CreationCollisionOption.replaceExisting)

                    .then(

    function(foldername) {

                        Windows.Storage.StorageFile.getFileFromApplicationUriAsync(

    newWindows.Foundation.Uri("ms-appx:///images/logo.png")).done(function(filesource) {

                            filesource.copyAsync(foldername.path, filesource.displayName, Windows.Storage.CreationCollisionOption.replaceExisting).done();

                        })

                    },

                   

    function(error) {

                    },

                   

    function(onProgress) {

                    });

    thank you if you able to see the issue


    thanks & regards chandresh soni

    Friday, November 2, 2012 11:48 AM

Answers

  • Hi,

    Please refer to the example as follow:

    //var jsonText = JSON.stringify(activitiesArray)
        var jsonText="hey, I am transfered";
    
        var localFolder = Windows.Storage.ApplicationData.current.localFolder;
        //localFolder.createFileAsync("myfile.data", Windows.Storage.CreationCollisionOption.replaceExisting)
        //    .then(function (file) {
        //        return Windows.Storage.FileIO.writeTextAsync(file, jsonText);
        //    });
    
    
        localFolder.getFileAsync("myfile.data")
                        .then(function (file) {
                            return Windows.Storage.FileIO.readTextAsync(file);
                        }).done(function (text) {
                            // activitiesArray = JSON.parse(text);
                            document.getElementById("content").innerHTML=text;
                        });


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Tuesday, November 13, 2012 6:49 AM
    Monday, November 5, 2012 8:32 AM