c# - Auto Extract a zip file -
I am trying to create a program that removes a specific zip file at the beginning of the program.
This is my code for creating a zip file:
// Creating file zipfile file = new zip file (system. Environment.gatefolderpath (environment specialfolder. Documents) + "\\ ABC.Jip"); // File Adding Files. Adfile (system environment.getfolderpath (environment specialfilter mydocuments) + "\ \ ab.dat", ""); File. Adfile (system environment.getfolderpath (environment specialfolder MyDocuments) + "\\ cd.dat", ""); // Save the file file. Save ();
I want to extract files ab.dat and cd.dat from ABCD.zip to the .exe file directory .
mostly taken from:
Remove Private Zero () {// Zip Position String zipToUnpack = System.Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments) + "\\ ABCD.zip"; // .EXE directory string unpack directory = System.IO.Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly (.pstation)); (Zip file zip = zipfile.read (ziptoupac)) {foreach (zip entry in zip) {// if the filename matches (e.FileName == "ab.dat" || e.FileName == "cd.dat ") E. Extract (unpack directory, extractexingfile action, overwrite seal); }
You can filter the results by selecting files here by using ExtractSelectEntries
:
zip.ExtractSelectedEntries ( "Name = 'ab.dat' or name = 'cd.dat' ',' \", unpack directory, extractexingfile action, overwrite cylinders) or or all .at < / Code> select files wildcard
zip.ExtractSelectedEntries ("name = '* .dat'", "\", unpack directory, extractexingfile action, overwrite silley)
< / Pre> Use each < Code> ZipEntry
's file name
property to see if its name is what you want to remove.
Comments
Post a Comment