i wrote program unzip file (.zip) using sharpziplib...
the following code:
public void unzip(string zipfilepath, string extractionpath) { fastzip fz = new fastzip(); fz.extractzip(zipfilepath, extractionpath, null); }
i following exception:
additional information: access path "c:\program files (x86)\... thumbs.db"
refused.
program starts admin rights , file "thumbs.db"
not exist in .zip archive.
who knows further?
greets , thanks!
i ignore "thumbs.db" file os file.
maybe this:
using icsharpcode.sharpziplib.core; using icsharpcode.sharpziplib.zip; public void extractzipfile(string archivefilenamein, string password, string outfolder) { zipfile zf = null; try { filestream fs = file.openread(archivefilenamein); zf = new zipfile(fs); if (!string.isnullorempty(password)) { zf.password = password; // aes encrypted entries handled automatically } foreach (zipentry zipentry in zf) { if (!zipentry.isfile) { continue; // ignore directories } string entryfilename = zipentry.name; // remove folder entry:- entryfilename = path.getfilename(entryfilename); // optionally match entrynames against selection list here skip desired. // unpacked length available in zipentry.size property. byte[] buffer = new byte[4096]; // 4k optimum stream zipstream = zf.getinputstream(zipentry); // manipulate output filename here desired. string fullziptopath = path.combine(outfolder, entryfilename); string directoryname = path.getdirectoryname(fullziptopath); if (directoryname.length > 0) directory.createdirectory(directoryname); // unzip file in buffered chunks. fast unpacking buffer full size // of file, not waste memory. // "using" close stream if exception occurs. using (filestream streamwriter = file.create(fullziptopath)) { streamutils.copy(zipstream, streamwriter, buffer); } } } { if (zf != null) { zf.isstreamowner = true; // makes close shut underlying stream zf.close(); // ensure release resources } } }
Comments
Post a Comment