c# - UWP ZipFile.CreateFromDirectory -


i have following code

private static async task createzipfile(string folderpath) {     await task.run(() =>     {         try         {             zipfile.createfromdirectory(folderpath, applicationdata.current.localfolder.path + "backup.zip");         }         catch (exception e)         {             ;         }     }); } 

in uwp app. getting access denied errors on localfolder. directory trying zip in localstate folder

folderpath = c:\users\username\appdata\local\packages\myapp_3y0bchp7kwvet\localstate\backup 

any ideas how resolve? other code has no problem accessing these folders.

i'd think problem here you've used wrong path destinationarchivefilename in zipfile.createfromdirectory method.

for valid path, should applicationdata.current.localfolder.path + "\\backup.zip".

once changed code following, should able work.

zipfile.createfromdirectory(folderpath, applicationdata.current.localfolder.path + "\\backup.zip"); 

Comments