locked
CopyAsync to copy SQLite Db file doesnot work RRS feed

  • Question

  • Hi All,

    I have Windows 8 native app developed in javascript as presentation layer and Windows Runtime component deveoped in C# .The problem arises when I try to copy the file from the physical location to the local storage folder of teh Windows 8 App.

    The section of code that does the same is as given below:

    var uri = new Windows.Foundation.Uri("ms-appx:///MyDB.db");

                Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(
                    function (file) {

                        var destinationFolder = Windows.Storage.ApplicationData.current.localFolder;
                        file.copyAsync(destinationFolder)

                    }

    Please suggest what is the other way of doing it .Kindly let me know if there is something wrong with the existing method or if there is  a better way of doing this .

    Thanks & regards,

    Syama Sasi.

    Thursday, December 5, 2013 4:18 AM

Answers

  • Hi Syama,

    I'm not sure what you mean by current package location vs. physical location.

    I confirmed that (barring the missing semicolon and closing the done() clause) your sample code works correctly if the db file is in the appx package root. Make sure that you have added it to the root of your project and set its Package Action property to "Content". This should ensure it gets deployed with the appx package.

    You can confirm that it is in the appx package install directory after deploying. If you are running from Visual Studio look inside your solution directory to make sure bin\Debug\AppX\MyDB.db is there (or bin\Release\... if you're running release mode.

    --Rob


    Friday, December 6, 2013 12:51 AM
    Moderator

All replies

  • Hi All,

    I have Windows 8 native app developed in javascript as presentation layer and Windows Runtime component deveoped in C# .The problem arises when I try to copy the file from the physical location to the local storage folder of teh Windows 8 App.

    The section of code that does the same is as given below:

    var uri = new Windows.Foundation.Uri("ms-appx:///MyDB.db");

                Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(
                    function (file) {

                        var destinationFolder = Windows.Storage.ApplicationData.current.localFolder;
                        file.copyAsync(destinationFolder)

                    }

    Please suggest what is the other way of doing it .Kindly let me know if there is something wrong with the existing method or if there is  a better way of doing this .

    Thanks & regards,

    Syama Sasi.


    Wednesday, December 4, 2013 10:22 AM
  • Hi Syama,

    You'll get better help with coding questions if you post in the appropriate development forum for the language you are using (in this case: Building Windows Store apps with HTML5/JavaScript)

    Your code looks superficially correct. What error are you getting? Have you confirmed that MyDB.db is copied to the root of your install directory?

    --Rob

    Thursday, December 5, 2013 3:14 AM
    Moderator
  • Hi Rob,

    Thank you wil take it to the appropriate forum .The problem I am facing is the .db file doesnt get copied to the mentioned location the problem arises only in windows 8.0 machine where as the same works in windows 8.1 machine .

    The code mentioned above has access to the file in package folder but how does the file gets shipped to package folder? Is there a mechanism to access  a physically present file in javascript or in c# .

    I searched for hours togeather and the end result was we have syntaxes that access the current package location not the physical location.

    Thanks & regards,

    Thursday, December 5, 2013 4:17 AM
  • Hi Syama,

    I'm not sure what you mean by current package location vs. physical location.

    I confirmed that (barring the missing semicolon and closing the done() clause) your sample code works correctly if the db file is in the appx package root. Make sure that you have added it to the root of your project and set its Package Action property to "Content". This should ensure it gets deployed with the appx package.

    You can confirm that it is in the appx package install directory after deploying. If you are running from Visual Studio look inside your solution directory to make sure bin\Debug\AppX\MyDB.db is there (or bin\Release\... if you're running release mode.

    --Rob


    Friday, December 6, 2013 12:51 AM
    Moderator