c# - TrySetWallpaperImageAsync always returns false even though I'm using Application LocalFolder -
the trywallpaperimageasync method returns false , not set wallpaper. if @ question: trysetwallpaperimageasync() returns false, see fix relocating image application's localfolder. doing here, reason wallpaper still not being changed. cause method fail?
string name = "wallpaper.jpg"; var file = await storagefile.getfilefrompathasync($"{applicationdata.current.localfolder.path}\\{name}"); var success = await setwallpaperasync(file); async task<bool> setwallpaperasync(storagefile fileitem) { bool success = false; if (userprofilepersonalizationsettings.issupported()) { userprofilepersonalizationsettings profilesettings = userprofilepersonalizationsettings.current; success = await profilesettings.trysetlockscreenimageasync(fileitem); } return success; }
there documented limitation api when dealing duplicate filenames.
if file trying set wallpaper has same name current wallpaper, system ignore request , no-op operation (returning false).
you should use unique filename when setting wallpaper ensure gets set correctly.
Comments
Post a Comment