private Hashtable searchInCompressed(FileInfo fi, string in_searchstring) { Hashtable ht_ret = new Hashtable(); if (fi.Extension.ToLower().Equals(".zip")) { zip.Zip.ZipFile zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(fi.FullName); IEnumerator ienumk = zf.GetEnumerator(); ienumk.MoveNext(); do { GC.Collect(); Application.DoEvents(); try { zip.Zip.ZipEntry ze = (zip.Zip.ZipEntry)ienumk.Current; if (ze.Name.ToLower().IndexOf(in_searchstring) != -1) { ht_ret.Add(ht_ret.Count, ze); } } catch (Exception ex) { } } while (ienumk.MoveNext()); } return(ht_ret); }
private void AddZipInfo(FileInfo in_fi, ListView in_lv) { zip.Zip.ZipFile zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(in_fi.FullName); IEnumerator ienumk = zf.GetEnumerator(); ienumk.MoveNext(); do { GC.Collect(); Application.DoEvents(); try { zip.Zip.ZipEntry ze = (zip.Zip.ZipEntry)ienumk.Current; if (ze.IsFile) { string strName = ze.Name; string strParent = in_fi.Name; if (strName.IndexOf("/") != -1) { string[] strNameArr = strName.Split(Encoding.Default.GetChars(Encoding.Default.GetBytes("/"))); strName = strNameArr[strNameArr.Length - 1]; strParent += "\\" + strNameArr[strNameArr.Length - 2]; } ListViewItem lvi = in_lv.Items.Add(strName); lvi.SubItems.Add(strParent); lvi.SubItems.Add(getRealSize(ze.Size)); lvi.SubItems.Add(ze.DateTime.ToShortDateString() + " " + ze.DateTime.ToLongTimeString()); ArrayList al = new ArrayList(); al.Add(in_fi); al.Add(zf); al.Add(ze); lvi.Tag = al; } } catch (Exception ex) { } } while (ienumk.MoveNext()); }
protected void Parse() { System.Collections.IEnumerator blah = zipFile.GetEnumerator(); while (blah.MoveNext()) { ICSCZL.Zip.ZipEntry theEntry = (ICSCZL.Zip.ZipEntry)blah.Current; if (theEntry.IsFile) { // if it's a file string extension = theEntry.Name.Substring(theEntry.Name.LastIndexOf(".")); if (extension == ".dfn") { // if it's a definition, let's do something with it dfnFiles.Add(theEntry.Name, new UOXData.Script.Script(zipFile.GetInputStream(theEntry))); } else if (extension == ".js") { // if it's a JS, time to copy over jsFiles.Add(theEntry.Name, ReadString(zipFile.GetInputStream(theEntry), theEntry.Size)); } } } }
private void AddZipInfo(FileInfo in_fi, ListView in_lv) { zip.Zip.ZipFile zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(in_fi.FullName); IEnumerator ienumk = zf.GetEnumerator(); ienumk.MoveNext(); do { GC.Collect(); Application.DoEvents(); try { zip.Zip.ZipEntry ze = (zip.Zip.ZipEntry)ienumk.Current; if (ze.IsFile) { string strName = ze.Name; string strParent = in_fi.Name; if (strName.IndexOf("/") != -1) { string[] strNameArr = strName.Split(Encoding.Default.GetChars(Encoding.Default.GetBytes("/"))); strName = strNameArr[strNameArr.Length-1]; strParent += "\\" + strNameArr[strNameArr.Length - 2]; } ListViewItem lvi = in_lv.Items.Add(strName); lvi.SubItems.Add(strParent); lvi.SubItems.Add(getRealSize(ze.Size)); lvi.SubItems.Add(ze.DateTime.ToShortDateString() + " " + ze.DateTime.ToLongTimeString()); ArrayList al = new ArrayList(); al.Add(in_fi); al.Add(zf); al.Add(ze); lvi.Tag = al; } } catch (Exception ex) { } } while (ienumk.MoveNext()); }
private void cmdSelectPackage_Click(object sender, System.EventArgs e) { opnFileDialog.Filter = "Package files (*.zip)|*.zip|All files (*.*)|*.*"; if (opnFileDialog.ShowDialog() == DialogResult.OK) { listPackageFiles.Items.Clear(); setupInfo = null; txtPackageDetails.Text = ""; currentZip = opnFileDialog.FileName; zipFile = new ICSCZL.Zip.ZipFile(currentZip); System.Collections.IEnumerator blah = zipFile.GetEnumerator(); while (blah.MoveNext()) { this.listPackageFiles.Items.Add(blah.Current); ICSCZL.Zip.ZipEntry theEntry = (ICSCZL.Zip.ZipEntry)blah.Current; if (theEntry.Name == "readme.txt") { int size = 2048; byte[] toDisp = new byte[2048]; System.IO.Stream s = zipFile.GetInputStream(theEntry); while (true) { size = s.Read(toDisp, 0, toDisp.Length); if (size > 0) { for (int i = 0; i < size; ++i) { this.txtPackageDetails.Text += (char)toDisp[i]; } } else { break; } } } else if (theEntry.Name == "setup.info") { System.IO.Stream s = zipFile.GetInputStream(theEntry); setupInfo = new UOXData.Script.Script(s); pkgConfig = new SetupInfo(iniScript); pkgConfig.Parse(setupInfo); } } mPackage = new Package(zipFile, pkgConfig); if (setupInfo == null) { System.Windows.Forms.MessageBox.Show("Zip file does not contain a setup.info! Likely an invalid package"); } } else { currentZip = ""; if (zipFile != null) { zipFile = null; } setupInfo = null; } }
private Hashtable searchInCompressed(FileInfo fi,string in_searchstring) { Hashtable ht_ret = new Hashtable(); if (fi.Extension.ToLower().Equals(".zip")) { zip.Zip.ZipFile zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(fi.FullName); IEnumerator ienumk = zf.GetEnumerator(); ienumk.MoveNext(); do { GC.Collect(); Application.DoEvents(); try { zip.Zip.ZipEntry ze = (zip.Zip.ZipEntry)ienumk.Current; if (ze.Name.ToLower().IndexOf(in_searchstring) != -1) { ht_ret.Add(ht_ret.Count, ze); } } catch (Exception ex) { } } while (ienumk.MoveNext()); } return ht_ret; }