c# - Why OneDrive Upload fails? -
i have function upload serialized data (mydata) onedrive.
private async void upload_click( object sender, system.eventargs e ) { if ( livehelper.session == null ) { var livestatus = await livehelper.initauth( app.clientid ); await livehelper.loadliveprofile(); } const string mydatafoldr = "mydata"; string folderid = await livehelper.getfolderid( mydatafoldr ); folderid = ( string.isnullorempty( folderid ) ? await livehelper.createfolder( livehelper.rootfolder, mydatafoldr ) : folderid ); string fileid = await livehelper.backgrounduploadfile( folderid, _app.mydata, app.skydrivefilename ); } public static async task<string> backgrounduploadfile<t>( string skydrivefolderid, t objecttoserialize, string filenameinskydrive, backgroundtransferpreferences backgroundtransferpreferences = backgroundtransferpreferences.allowcellularandbattery ) { string fileid = string.empty; try { var storagefolder = await getsharedtransfersfolder(); storagefile isolatedstoragefile = await storagefolder.createfileasync( filenameinskydrive, creationcollisionoption.replaceexisting ); using ( var writer = new streamwriter( await isolatedstoragefile.openstreamforwriteasync() ) ) { // convert string var _string = serialize( objecttoserialize ); await writer.writeasync( _string ); } client.backgroundtransferpreferences = backgroundtransferpreferences; liveoperationresult liveopresult = await client.backgrounduploadasync( skydrivefolderid, new uri( @"\shared/transfers\" + filenameinskydrive, urikind.relative ), overwriteoption.overwrite ); fileid = (string)liveopresult.result[ "id" ]; debug.writeline( "backgrounduploadfile: " + filenameinskydrive ); } catch ( exception e ) { debug.writeline( "\nerror - backgrounduploadfile: " + e.message ); } return fileid; }
when testing function using emulator/debugger combination data uploaded properly.
i tested code on phone, , ran under device/debugger , device/release combination. under both combinations data uploaded properly.
however when publishing application , trying upload data, data not being uploaded on same phone of step #2. (on phone, different live id, upload works fine).
the same phone step #3 able download data onedrive (the data there steps #2 & #3).
can explain why upload fails in case?
Comments
Post a Comment