c# - Can't Delete zip files after extracting them -
i have method extracts multiple zip files can't delete them until application close. think it's bug in dotnetzip version 1.9.1.5 library.
my zip files:
hezareh.z01 hezareh.z02 hezareh.z03 hezareh.zip code extract files:
private void installupdates() { string tempdir = path.combine(environment.currentdirectory, mainviewmodel.temporarydirectoryname); string mainzipfilename = path.combine(tempdir, _updateconfig.zipfiles.single(f => f.isfirstpart).pathonclient); // i'm sure hezareh.zip file string installpath = path.combine(environment.currentdirectory, properties.settings.default.installationdirectory); // tried: using (var zipfile = new zipfile(mainzipfilename)) using (var zipfile = zipfile.read(mainzipfilename)) { // same problem extractall method. // zipfile.extractall(installpath, extractexistingfileaction.overwritesilently); foreach (zipentry entiry in zipfile) { entiry.extract(installpath, extractexistingfileaction.overwritesilently); } // zipfile.close() or same method not exists , zipfile.dispose() called // automatically when call manually still have same problem. } deletefiles(); } private void deletefiles() { var files = directory.getfiles(path.combine(environment.currentdirectory, mainviewmodel.temporarydirectoryname)); foreach (string file in files) { file.delete(file); // exception occure here } } this question did not work me , i'm going burn head.
exception:
process cannot access file 'd:\projects\...\app\bin\debug\updatertemp\hezareh.z01' because being used process. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.delete(string path) @ meshkat.updater.app.viewmodels.installupdatesviewmodel.deletedownloadedupdates() in d:\projects\meshkat.updater\meshkat.updater.app\viewmodels\installupdatesviewmodel.cs:line 60 @ meshkat.updater.app.viewmodels.installupdatesviewmodel.hide() in d:\projects\meshkat.updater\meshkat.updater.app\viewmodels\installupdatesviewmodel.cs:line 129 @ meshkat.updater.app.relaycommand.execute(object parameter) in d:\projects\meshkat.updater\meshkat.updater.app\relaycommand.cs:line 146 @ ms.internal.commands.commandhelpers.criticalexecutecommandsource(icommandsource commandsource, boolean userinitiated) @ system.windows.controls.primitives.buttonbase.onclick() @ system.windows.controls.button.onclick() @ system.windows.controls.primitives.buttonbase.onmouseleftbuttonup(mousebuttoneventargs e) @ system.windows.uielement.onmouseleftbuttonupthunk(object sender, mousebuttoneventargs e) @ system.windows.input.mousebuttoneventargs.invokeeventhandler(delegate generichandler, object generictarget) @ system.windows.routedeventargs.invokehandler(delegate handler, object target) @ system.windows.routedeventhandlerinfo.invokehandler(object target, routedeventargs routedeventargs) @ system.windows.eventroute.invokehandlersimpl(object source, routedeventargs args, boolean reraised) @ system.windows.uielement.reraiseeventas(dependencyobject sender, routedeventargs args, routedevent newevent) @ system.windows.uielement.crackmousebuttoneventandreraiseevent(dependencyobject sender, mousebuttoneventargs e) @ system.windows.uielement.onmouseupthunk(object sender, mousebuttoneventargs e) @ system.windows.input.mousebuttoneventargs.invokeeventhandler(delegate generichandler, object generictarget) @ system.windows.routedeventargs.invokehandler(delegate handler, object target) @ system.windows.routedeventhandlerinfo.invokehandler(object target, routedeventargs routedeventargs) @ system.windows.eventroute.invokehandlersimpl(object source, routedeventargs args, boolean reraised) @ system.windows.uielement.raiseeventimpl(dependencyobject sender, routedeventargs args) @ system.windows.uielement.raiseevent(routedeventargs args, boolean trusted) @ system.windows.input.inputmanager.processstagingarea() @ system.windows.input.inputmanager.processinput(inputeventargs input) @ system.windows.input.inputprovidersite.reportinput(inputreport inputreport) @ system.windows.interop.hwndmouseinputprovider.reportinput(intptr hwnd, inputmode mode, int32 timestamp, rawmouseactions actions, int32 x, int32 y, int32 wheel) @ system.windows.interop.hwndmouseinputprovider.filtermessage(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled) @ system.windows.interop.hwndsource.inputfiltermessage(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled) @ ms.win32.hwndwrapper.wndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam, boolean& handled) @ ms.win32.hwndsubclass.dispatchercallbackoperation(object o) @ system.windows.threading.exceptionwrapper.internalrealcall(delegate callback, object args, boolean issingleparameter) @ system.windows.threading.exceptionwrapper.trycatchwhen(object source, delegate callback, object args, boolean issingleparameter, delegate catchhandler) @ system.windows.threading.dispatcher.wrappedinvoke(delegate callback, object args, boolean issingleparameter, delegate catchhandler) @ system.windows.threading.dispatcher.invokeimpl(dispatcherpriority priority, timespan timeout, delegate method, object args, boolean issingleparameter) @ system.windows.threading.dispatcher.invoke(dispatcherpriority priority, delegate method, object arg) @ ms.win32.hwndsubclass.subclasswndproc(intptr hwnd, int32 msg, intptr wparam, intptr lparam) @ ms.win32.unsafenativemethods.dispatchmessage(msg& msg) @ system.windows.threading.dispatcher.pushframeimpl(dispatcherframe frame) @ system.windows.threading.dispatcher.pushframe(dispatcherframe frame) @ system.windows.threading.dispatcher.run() @ system.windows.application.rundispatcher(object ignore) @ system.windows.application.runinternal(window window) @ system.windows.application.run(window window) @ system.windows.application.run() @ meshkat.updater.app.app.main() in d:\projects\meshkat.updater\meshkat.updater.app\obj\x86\debug\app.g.cs:line 0 @ system.appdomain._nexecuteassembly(assembly assembly, string[] args) @ system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args) @ microsoft.visualstudio.hostingprocess.hostproc.runusersassembly() @ system.threading.threadhelper.threadstart_context(object state) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state) @ system.threading.threadhelper.threadstart()
versions prior v1.9.1.6 had bug couldn't delete files after extracted. perhaps need upgrade? tell version.
for more information see workitem on codeplex: http://dotnetzip.codeplex.com/workitem/12521
Comments
Post a Comment