c# - How to Use IsolatedStorage to Set Lock Screen Background in Windows Phone 8 -


i able use image isolatedstorage modify lock screen background, having trouble getting correct syntax of isolatedstorage file path set lock screen background.

in following http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206968(v=vs.105).aspx , calling lockhelper method in button click event once image has been selected list named recent (which has been populated picturerepository.cs loads images isolatedstorage)

private void recent_selectionchanged(object sender, selectionchangedeventargs e)     {                     capturedpicture = (sender longlistselector).selecteditem capturedpicture;          if (capturedpicture != null)         {             //filename name of image in isolatedstorage             filename = capturedpicture.filename;         }     }  void setaslockscreenmenuitem_click(object sender, eventargs e)     {         if (!string.isnullorempty(filename))          {             //picturerepository.isolatedstoragepath string = "pictures"                             lockhelper("isostore:/" + picturerepository.isolatedstoragepath + "/" + filename, false);  //results in filenotfoundexception             lockhelper(picturerepository.isolatedstoragepath + "/" + filename, false);  //results in argumentexception         }         else         {             messageboxresult result = messagebox.show("you must select image set lock screen.", "notice", messageboxbutton.ok);             if (result == messageboxresult.ok)             {                 return;             }         }     } 

once lockhelper called, event proceeds

private async void lockhelper(string filepathoftheimage, bool isappresource)     {         try         {             var isprovider = windows.phone.system.userprofile.lockscreenmanager.isprovidedbycurrentapplication;             if (!isprovider)             {                 // if you're not provider, call prompt user permission.                 // calling requestaccessasync background agent not allowed.                 var op = await windows.phone.system.userprofile.lockscreenmanager.requestaccessasync();                  // further work if access granted.                 isprovider = op == windows.phone.system.userprofile.lockscreenrequestresult.granted;             }              if (isprovider)             {                 // @ stage, app active lock screen background provider.                  // following code example shows new uri schema.                 // ms-appdata points root of local app data folder.                 // ms-appx points local app install folder, reference resources bundled in xap package.                 var schema = isappresource ? "ms-appx:///" : "ms-appdata:///local/";                 var uri = new uri(schema + filepathoftheimage, urikind.absolute);                  //the error occurs here!                 // set lock screen background image.                 windows.phone.system.userprofile.lockscreen.setimageuri(uri);                  // uri of lock screen background image.                 var currentimage = windows.phone.system.userprofile.lockscreen.getimageuri();                 system.diagnostics.debug.writeline("the new lock screen background image set {0}", currentimage.tostring());             }             else             {                 messageboxresult result = messagebox.show("cannot update lock screen background @ time.", "notice", messageboxbutton.ok);                 if (result == messageboxresult.ok)                 {                     return;                 }             }         }         catch (system.exception ex)         {             system.diagnostics.debug.writeline(ex.tostring());         }     } 

the error occurs on windows.phone.system.userprofile.lockscreen.setimageuri(uri); within lockhelper method. either filenotfoundexception mentioning the filename, directory name, or volume label syntax incorrect. (exception hresult: 0x8007007b) or argumentexception. everywhere i've referenced says using isolatedstorage uri should ms-appdata:///local/ , isolatedstorage file path (in case pictures/imagename.jpg), , believe error lies uri path, unsure of correct syntax? if not this, other ideas?

this worked me:

const string filepathoftheimage = "/shared/shellcontent/shot2.jpg"; //this image in isostore  var uri = new uri("ms-appdata:///local" + filepathoftheimage, urikind.absolute); 

also, use wp power tools tracking app storage space. hope helps.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -