/// <summary> /// Распаковка архива /// </summary> public static void RaspakovkaArhiva() { ZipForge archiver = new ZipForge(); NoVisiblePapka(); try { archiver.FileName = @"C:\test.zip"; //Необходимый файл archiver.OpenArchive(System.IO.FileMode.Open); //Указываем что хотим сделать // archiver.BaseDir = pathArhiv; //Папка куда распаковать archiver.BaseDir = pathArhivHille; //Папка куда распаковать //archiver.BaseDir = @"C:\1"; //Папка куда распаковать // archiver.ExtractFiles("*.exe"); //Распаковываем *.exe // archiver.ExtractFiles("*.dll"); //Распаковываем *.dll archiver.ExtractFiles("*.*"); //archiver.BaseDir = @"D:\"; // archiver.ExtractFiles("*.txt"); //Распаковываем *.txt но можем и просто файл archiver.ExtractFiles("test"); //Распаковываем папку archiver.CloseArchive(); Console.WriteLine("Архив разохвивирован"); } // Catch all exceptions of the ArchiverException type catch (ArchiverException ae) { Console.WriteLine("Message: {0}\t Ошибка при архивации: {1}", ae.Message, ae.ErrorCode); Console.ReadLine(); } }
public static Boolean UnZipFile(string fileName_Ext, string filesDestination) { Boolean unZipStatus = true; ZipForge archiver = new ZipForge(); try { // The name of the ZIP file to unzip archiver.FileName = fileName_Ext; // Open an existing archive archiver.OpenArchive(System.IO.FileMode.Open); // Default path for all operations archiver.BaseDir = filesDestination; // Extract all files from the archive to C:\Temp folder archiver.ExtractFiles("*.*"); // Close archive archiver.CloseArchive(); } // Catch all exceptions of the ArchiverException type catch (ArchiverException ae) { unZipStatus = false; } return(unZipStatus); }
private void button3_Click( object sender, EventArgs e ) { OFD.Filter = "Varocal Package File (*.vpak)|*.vpak|Anyfile (*.*)|*.*"; if ( OFD.ShowDialog( ) == System.Windows.Forms.DialogResult.OK ) { var v = new ZipForge( ); v.FileName = OFD.FileName; v.OpenArchive( System.IO.FileMode.Open ); v.BaseDir = Path.GetFullPath( "pkgcmp" ); v.ExtractFiles( "*.*" ); new Thread( new ThreadStart( ( ) => { new PackageInstallation( "pkgcmp" ).ShowDialog( ); this.BeginInvoke( new MethodInvoker( ( ) => { ChooseReference_Load( null, null ); } ) ); } ) ).Start( ); } }
static void TestUnzip() { ZipForge archiver = new ZipForge(); try { // The name of the ZIP file to unzip archiver.FileName = @"C:\Users\charl\source\repos\ConsoleApp3\bin\Debug\output\AdvEvent.txt.zip"; // Open an existing archive archiver.OpenArchive(System.IO.FileMode.Open); // Default path for all operations archiver.BaseDir = @"D:\Temp"; // Extract all files from the archive to C:\Temp folder archiver.ExtractFiles("*.*"); // Close archive archiver.CloseArchive(); } // Catch all exceptions of the ArchiverException type catch (ArchiverException ae) { Console.WriteLine("Message: {0}\t Error code: {1}", ae.Message, ae.ErrorCode); } }
private void installPackageToolStripMenuItem_Click( object sender, EventArgs e ) { OFD.Filter = "Varocal Package File (*.vpak)|*.vpak|Anyfile (*.*)|*.*"; if ( OFD.ShowDialog( )==System.Windows.Forms.DialogResult.OK ) { var v = new ZipForge( ); v.FileName = OFD.FileName; v.OpenArchive( System.IO.FileMode.Open ); v.BaseDir = Path.GetFullPath( "pkgcmp" ); v.ExtractFiles("*.*"); new Thread( new ThreadStart( ( ) => { new PackageInstallation( "pkgcmp" ).ShowDialog( ); } ) ).Start( ); } }
private void fILEToolStripMenuItem1_Click(object sender, EventArgs e) { OpenFileDialog browsefile = new OpenFileDialog(); // string []arr; browsefile.Title = "browse file"; browsefile.Filter="Zip Files|*.zip"; if(browsefile.ShowDialog()==DialogResult.Cancel) return; Class1.location = browsefile.FileName; // string[] words = s.Split(' '); // string[] arr= Class1.location.Split('.'); string pattt= Path.GetFileNameWithoutExtension(Class1.location);//extracts only anil if anil.zip was there. string xfilename=pattt+".xml"; Class1.rtfname = pattt + ".rtf"; Class1.location2 = Path.Combine("C:\\Users\\Vyshak\\Desktop\\READERTOOL", pattt); Class1.xmlfilelocation = Path.Combine(Class1.location2,xfilename); Class1.rtffilelocation = Path.Combine(Class1.location2,Class1.rtfname); // MessageBox.Show(pattt); // Class1.location2=arr[0]; //UNZIP STARTED ZipForge archiver = new ZipForge(); try { // The name of the ZIP file to unzip archiver.FileName = Class1.location; // Open an existing archive archiver.Password = "******"; archiver.OpenArchive(System.IO.FileMode.Open); // Default path for all operations archiver.BaseDir ="C:\\Users\\Vyshak\\Desktop\\READERTOOL"; // Extract all files from the archive to C:\Temp folder archiver.ExtractFiles("*.*"); // Close archive archiver.CloseArchive(); } // Catch all exceptions of the ArchiverException type catch (ArchiverException ae) { Console.WriteLine("Message: {0}\t Error code: {1}", ae.Message, ae.ErrorCode); // Wait for keypress Console.ReadLine(); } //UNZIP COMPLETE Class1.xsdlocation= Path.Combine(Class1.location2, "proj.xsd"); FileStream aFile = new FileStream(Class1.xsdlocation, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(aFile); sw.WriteLine("<?xml version=\"1.0\"?>"); sw.WriteLine("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""); sw.WriteLine("targetNamespace=\"http://www.manual.org\" xmlns=\"http://www.manual.org\" elementFormDefault=\"qualified\">"); sw.WriteLine("<xsd:element name=\"Manual\">"); sw.WriteLine("<xsd:complexType>"); sw.WriteLine("<xsd:sequence>"); sw.WriteLine("<xsd:element ref=\"doc\" minOccurs=\"1\" maxOccurs=\"unbounded\"/>"); sw.WriteLine("</xsd:sequence>"); sw.WriteLine("</xsd:complexType>"); sw.WriteLine("</xsd:element>"); sw.WriteLine("<xsd:element name=\"doc\">"); sw.WriteLine("<xsd:complexType>"); sw.WriteLine("<xsd:choice minOccurs=\"5\" maxOccurs=\"5\">"); sw.WriteLine("<xsd:element ref=\"Text\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"Image\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"Video\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"Flash\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"Audio\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"QA\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"Richtext\" minOccurs=\"0\" maxOccurs=\"1\"/>"); sw.WriteLine("<xsd:element ref=\"Tempnum\" minOccurs=\"1\" maxOccurs=\"1\"/>"); sw.WriteLine("</xsd:choice></xsd:complexType></xsd:element>"); sw.WriteLine("<xsd:element name=\"Text\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"Image\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"Video\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"Flash\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"Audio\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"Richtext\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"Tempnum\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"QA\">"); sw.WriteLine("<xsd:complexType>"); sw.WriteLine("<xsd:sequence>"); sw.WriteLine("<xsd:element name=\"QUESTION\" type=\"xsd:string\"/>"); sw.WriteLine("<xsd:element name=\"ANSWER1\" type=\"xsd:string\" />"); sw.WriteLine("<xsd:element name=\"ANSWER2\" type=\"xsd:string\" />"); sw.WriteLine("<xsd:element name=\"ANSWER3\" type=\"xsd:string\" />"); sw.WriteLine("<xsd:element name=\"ANSWER4\" type=\"xsd:string\" />"); sw.WriteLine("<xsd:element name=\"CORRECTANSWER\" type=\"xsd:string\" />"); sw.WriteLine("</xsd:sequence>"); sw.WriteLine("</xsd:complexType>"); sw.WriteLine("</xsd:element>"); sw.WriteLine("</xsd:schema>"); sw.Close(); aFile.Close(); //validation start bool isValid = true; //xml validation // Console.Write("hai"); //Console.WriteLine("The xml file is" + isValid); try { XmlReaderSettings settings = new XmlReaderSettings(); settings.Schemas.Add(null, Class1.xsdlocation); settings.ValidationType = ValidationType.Schema; XmlDocument document = new XmlDocument(); document.Load(Class1.xmlfilelocation); XmlReader rdr = XmlReader.Create(new StringReader(document.InnerXml), settings); while (rdr.Read()) { } } catch { MessageBox.Show("Validation failed..Corrupted file"); this.Close(); } Console.WriteLine("The xml file is" + isValid); //validation end XmlTextReader reader1 = new XmlTextReader(Class1.xmlfilelocation); while (reader1.Read()) { if (reader1.Name == "Tempnum") { Class1.NUM = reader1.ReadString(); // MessageBox.Show(Class1.NUM); } } XmlTextReader reader = new XmlTextReader(Class1.xmlfilelocation); while (reader.Read()) { // MessageBox.Show("hai"); if (Class1.NUM =="1") { groupBox1.Visible = true; // MessageBox.Show(Class1.NUM); if (reader.Name == "QUESTION") textBox3.Text = reader.ReadString(); if (reader.Name == "ANSWER1") radioButton1.Text = reader.ReadString(); if (reader.Name == "ANSWER2") radioButton2.Text = reader.ReadString(); if (reader.Name == "ANSWER3") radioButton3.Text = reader.ReadString(); if (reader.Name == "ANSWER4") radioButton4.Text = reader.ReadString(); /*if (reader.Name == "Image") { string imagepath1 = Path.Combine("C:\\Users\\Vyshak\\Desktop\\target\\Vyshak", reader.ReadString()); Image image = Image.FromFile(imagepath1); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new Size(100, 100); pictureBox1.Image = image; * }*/ if (reader.Name == "Richtext") { richTextBox1.LoadFile(Class1.rtffilelocation, RichTextBoxStreamType.RichText); } if (reader.Name == "Text") { textBox1.Text = reader.ReadString(); } if (reader.Name == "Image") { string imagepath1 = Path.Combine(Class1.location2, reader.ReadString()); // MessageBox.Show(imagepath1); Image image = Image.FromFile(imagepath1); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new Size(100, 100); //pictureBox2.Height = image.Height; // pictureBox2.Width = image.Width; pictureBox1.Image = image; // pictureBox1.Image = reader.ReadString; } } if (Class1.NUM =="2") { groupBox2.Visible = true; toolStripButton1.Enabled = true; toolStripButton2.Enabled = false; toolStripButton3.Enabled = false; if (reader.Name == "QUESTION") textBox6.Text = reader.ReadString(); if (reader.Name == "ANSWER1") radioButton5.Text = reader.ReadString(); if (reader.Name == "ANSWER2") radioButton6.Text = reader.ReadString(); if (reader.Name == "ANSWER3") radioButton7.Text = reader.ReadString(); if (reader.Name == "ANSWER4") radioButton8.Text = reader.ReadString(); /*if (reader.Name == "Image") { string imagepath1 = Path.Combine("C:\\Users\\Vyshak\\Desktop\\target\\Vyshak", reader.ReadString()); Image image = Image.FromFile(imagepath1); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Size = new Size(100, 100); pictureBox1.Image = image; * }*/ if (reader.Name == "Video") { Class1.videolocation = Path.Combine(Class1.location2, reader.ReadString()); } if (reader.Name == "Text") { textBox4.Text = reader.ReadString(); } if (reader.Name == "Richtext") { richTextBox2.LoadFile(Class1.rtffilelocation, RichTextBoxStreamType.RichText); } } if (Class1.NUM == "3") { groupBox3.Visible = true; if (reader.Name == "QUESTION") textBox8.Text = reader.ReadString(); if (reader.Name == "ANSWER1") radioButton9.Text = reader.ReadString(); if (reader.Name == "ANSWER2") radioButton10.Text = reader.ReadString(); if (reader.Name == "ANSWER3") radioButton11.Text = reader.ReadString(); if (reader.Name == "ANSWER4") radioButton12.Text = reader.ReadString(); if (reader.Name == "Richtext") { richTextBox3.LoadFile(Class1.rtffilelocation, RichTextBoxStreamType.RichText); } if (reader.Name == "Audio") { Class1.audiopath = Path.Combine(Class1.location2, reader.ReadString()); } if (reader.Name == "Image") { string imagepath1 = Path.Combine(Class1.location2, reader.ReadString()); // MessageBox.Show(imagepath1); Image image = Image.FromFile(imagepath1); pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox2.Size = new Size(100, 100); //pictureBox2.Height = image.Height; // pictureBox2.Width = image.Width; pictureBox2.Image = image; // pictureBox1.Image = reader.ReadString; } } if (Class1.NUM == "4") { groupBox4.Visible = true; if (reader.Name == "Richtext") { richTextBox4.LoadFile(Class1.rtffilelocation, RichTextBoxStreamType.RichText); } if (reader.Name == "Image") { string imagepath1 = Path.Combine(Class1.location2, reader.ReadString()); // MessageBox.Show(imagepath1); Image image = Image.FromFile(imagepath1); pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage; //pictureBox3.Size = new Size(100, 100); //pictureBox2.Height = image.Height; // pictureBox2.Width = image.Width; pictureBox3.Image = image; // pictureBox1.Image = reader.ReadString; } if (reader.Name == "Video") { Class1.videolocation = Path.Combine(Class1.location2, reader.ReadString()); } if (reader.Name == "Flash") { Class1.flashpath = Path.Combine(Class1.location2,reader.ReadString()); axShockwaveFlash1.Movie = Class1.flashpath; //axShockwaveFlash1.Size = new System.Drawing.Size(100, 100); axShockwaveFlash1.Play(); } } } }
public static void natives() { ZipForge zipForge = new ZipForge(); if (!Directory.Exists(MocSystem.forgeDir + @"\" + "natives")) { Directory.CreateDirectory(MocSystem.forgeDir + @"\" + "natives"); } for(int i=0;i<minecraftLibFileName.Count;i++) { if (minecraftLibFileName[i].ToString().Contains("natives")) { minecraftNatives.Add(minecraftLibDir[i].ToString() + @"\" + minecraftLibFileName[i].ToString()); zipForge.FileName = minecraftLibDir[i].ToString() + @"\" + minecraftLibFileName[i].ToString(); zipForge.OpenArchive(System.IO.FileMode.Open); zipForge.BaseDir = MocSystem.forgeDir + @"\" + "natives"; zipForge.ExtractFiles("*.*"); zipForge.CloseArchive(); } } for (int i = 0; i < forgeNatives.Count; i++) { zipForge.FileName = MocSystem.libDir + @"\" + forgeNatives[i].ToString() + ".jar"; zipForge.OpenArchive(System.IO.FileMode.Open); zipForge.BaseDir = MocSystem.forgeDir + @"\" + "natives"; zipForge.ExtractFiles("*.*"); zipForge.CloseArchive(); } }
public static void forgeVersion() { WebClient myWebClient = new WebClient(); if (!File.Exists(MocSystem.verDir + @"\" +Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + @"\" +Profile.minecraftVersion + "-Forge" + Profile.forgeVersion+ ".jar")) { myWebClient.DownloadFile(@"http://s3.amazonaws.com/Minecraft.Download/versions/" + Profile.minecraftVersion + "/" + Profile.minecraftVersion + @".jar", MocSystem.verDir + @"\" + Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + @"\" + Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + @".jar"); } if (!File.Exists(MocSystem.verDir + @"\" + Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + @"\" + Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + ".json")) { ZipForge zipForge = new ZipForge(); zipForge.FileName = MocSystem.libDir + @"\net\minecraftforge\forge\1.7.10-10.13.2.1291\" + "forge-"+ Profile.minecraftVersion +"-"+Profile.forgeVersion+ @".jar"; zipForge.OpenArchive(System.IO.FileMode.Open); zipForge.BaseDir = MocSystem.verDir + @"\" + Profile.minecraftVersion + "-Forge" + Profile.forgeVersion; zipForge.RenameFile("version.json",Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + ".json"); zipForge.ExtractFiles(Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + ".json"); zipForge.RenameFile(Profile.minecraftVersion + "-Forge" + Profile.forgeVersion + ".json", "version.json"); zipForge.CloseArchive(); } }
public static bool UnzipFile(string path, string pass, string dir, string file) { try { using (var zpr = new ZipForge()) { zpr.FileName = path; zpr.OpenArchive(FileMode.Open); zpr.Password = pass; zpr.BaseDir = dir; zpr.ExtractFiles(file); } } catch (ArchiverException e) { Messaging.ThrowException("UnzipFile", e); return false; } catch (Exception e) { Messaging.ThrowException("UnzipFile", e); return false; } return true; }