c# - Why I can't upload sqlite file to the OneDrive? -


i developing windows runtime universal application.

i need upload database i'm using in application user's onedrive?

but filenotfound exception occurs. know path correct.

since refer sqlite file, shows exception. if refer txt file, uploading process goes smoothly.

var authclient = new liveauthclient(); var authresult = await authclient.loginasync(new string[] { "wl.skydrive", "wl.skydrive_update" }); if (authresult.session != null) {     var liveconnectclient = new liveconnectclient(authresult.session);     var filetoupload = await applicationdata.current.localfolder.getfileasync("text.sqlite");//exception occurs here             var filetoupload = await applicationdata.current.localfolder.getfileasync("text.txt");//no exception txt files      var folderdata = new dictionary<string, object>();     folderdata.add("name", "folder")      liveoperationresult operationresult = await liveconnectclient.postasync("me/skydrive", folderdata);      liveuploadoperation uploadoperation = await liveconnectclient.createbackgrounduploadasync(folderid, "filename", filetoupload, overwriteoption.overwrite);     liveoperationresult uploadresult = await uploadoperation.startasync();     handleuploadresult(uploadresult); } 

first, should use background transfer task move file large , handle occasion when user gets call during transfer. background tasks key.

http://code.msdn.microsoft.com/windowsapps/background-transfer-sample-d7833f61/sourcecode?fileid=52027&pathid=1495533284

sort of this.

backgrounduploader uploader = new backgrounduploader();  uploadoperation upload = uploader.createupload(uri, file);  await handleuploadasync(upload, true);  

but before that, need assume user manipulate database. result, should copy database file before start upload. again, code:

var sourcefolder = windows.storage.applicationdata.current.localfolder; var sourcefile = await sourcefolder.createfileasync("database",      windows.storage.creationcollisionoption.openifexists); var targetfolder = await sourcefolder.createfolderasync("~",      windows.storage.creationcollisionoption.openifexists); var targetfile = await targetfolder.createfileasync(sourcefile.name,     windows.storage.creationcollisionoption.replaceexisting); await sourcefile.moveandreplaceasync(targetfile); 

this not idea, have feeling correct problems having. remember can query , ask if transfer done (do aren't doing two).

best of luck!


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -