diff --git a/smolZIP.sln b/smolZIP.sln new file mode 100644 index 0000000..2d874fb --- /dev/null +++ b/smolZIP.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "smolZIP", "smolZIP\smolZIP.csproj", "{26AA0E0D-D336-47BB-B7B1-7BB383318507}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {26AA0E0D-D336-47BB-B7B1-7BB383318507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26AA0E0D-D336-47BB-B7B1-7BB383318507}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26AA0E0D-D336-47BB-B7B1-7BB383318507}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26AA0E0D-D336-47BB-B7B1-7BB383318507}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AE2DFE5D-8CAE-4A80-832D-C8823A2F0FA7} + EndGlobalSection +EndGlobal diff --git a/smolZIP/MainForm.Designer.cs b/smolZIP/MainForm.Designer.cs new file mode 100644 index 0000000..fbd69b1 --- /dev/null +++ b/smolZIP/MainForm.Designer.cs @@ -0,0 +1,102 @@ +namespace smolZIP +{ + partial class MainForm + { + private System.ComponentModel.IContainer components = null; + private System.Windows.Forms.Button btnExtractZip; + private System.Windows.Forms.Button btnCreateZip; + private System.Windows.Forms.ProgressBar progressBar; + private System.Windows.Forms.Label lblTitle; + private System.Windows.Forms.Label lblVersion; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + this.btnExtractZip = new System.Windows.Forms.Button(); + this.btnCreateZip = new System.Windows.Forms.Button(); + this.progressBar = new System.Windows.Forms.ProgressBar(); + this.lblTitle = new System.Windows.Forms.Label(); + this.lblVersion = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // btnExtractZip + // + this.btnExtractZip.BackColor = System.Drawing.Color.Transparent; + this.btnExtractZip.Location = new System.Drawing.Point(12, 325); + this.btnExtractZip.Name = "btnExtractZip"; + this.btnExtractZip.Size = new System.Drawing.Size(109, 43); + this.btnExtractZip.TabIndex = 2; + this.btnExtractZip.Text = "Extract ZIP"; + this.btnExtractZip.UseVisualStyleBackColor = false; + this.btnExtractZip.Click += new System.EventHandler(this.btnExtractZip_Click); + // + // btnCreateZip + // + this.btnCreateZip.Location = new System.Drawing.Point(190, 325); + this.btnCreateZip.Name = "btnCreateZip"; + this.btnCreateZip.Size = new System.Drawing.Size(104, 43); + this.btnCreateZip.TabIndex = 3; + this.btnCreateZip.Text = "Create ZIP"; + this.btnCreateZip.UseVisualStyleBackColor = true; + this.btnCreateZip.Click += new System.EventHandler(this.btnCreateZip_Click); + // + // progressBar + // + this.progressBar.Location = new System.Drawing.Point(12, 285); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(282, 23); + this.progressBar.TabIndex = 4; + // + // lblTitle + // + this.lblTitle.AutoSize = true; + this.lblTitle.BackColor = System.Drawing.Color.Transparent; + this.lblTitle.Font = new System.Drawing.Font("Space Mono", 14.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblTitle.ForeColor = System.Drawing.Color.White; + this.lblTitle.Location = new System.Drawing.Point(21, 109); + this.lblTitle.Name = "lblTitle"; + this.lblTitle.Size = new System.Drawing.Size(259, 28); + this.lblTitle.TabIndex = 0; + this.lblTitle.Text = "smolZIP by abrendan"; + this.lblTitle.Click += new System.EventHandler(this.lblTitle_Click); + // + // lblVersion + // + this.lblVersion.AutoSize = true; + this.lblVersion.BackColor = System.Drawing.Color.Transparent; + this.lblVersion.ForeColor = System.Drawing.Color.White; + this.lblVersion.Location = new System.Drawing.Point(225, 269); + this.lblVersion.Name = "lblVersion"; + this.lblVersion.Size = new System.Drawing.Size(69, 13); + this.lblVersion.TabIndex = 1; + this.lblVersion.Text = "Version 1.0.0"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.BackgroundImage = global::smolZIP.Properties.Resources.background1; + this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.ClientSize = new System.Drawing.Size(306, 380); + this.Controls.Add(this.lblTitle); + this.Controls.Add(this.lblVersion); + this.Controls.Add(this.progressBar); + this.Controls.Add(this.btnCreateZip); + this.Controls.Add(this.btnExtractZip); + this.Name = "MainForm"; + this.Text = "smolZIP"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + } +} \ No newline at end of file diff --git a/smolZIP/MainForm.cs b/smolZIP/MainForm.cs new file mode 100644 index 0000000..03d0b85 --- /dev/null +++ b/smolZIP/MainForm.cs @@ -0,0 +1,133 @@ +using System; +using System.ComponentModel; +using System.IO; +using System.Windows.Forms; +using ICSharpCode.SharpZipLib.Core; +using ICSharpCode.SharpZipLib.Zip; + +namespace smolZIP +{ + public partial class MainForm : Form + { + private const string AppVersion = "1.0.0"; + + public MainForm() + { + InitializeComponent(); + } + + // Extract ZIP File with progress + private void ExtractZip(string zipFilePath, string extractPath) + { + try + { + using (FileStream fs = File.OpenRead(zipFilePath)) + { + ZipFile zf = new ZipFile(fs); + progressBar.Maximum = (int)zf.Count; + progressBar.Value = 0; + + foreach (ZipEntry entry in zf) + { + if (!entry.IsFile) continue; + + string entryFileName = entry.Name; + byte[] buffer = new byte[4096]; + + // ZipFile.GetInputStream() returns a raw input stream. + using (Stream zipStream = zf.GetInputStream(entry)) + { + string fullZipToPath = Path.Combine(extractPath, entryFileName); + string directoryName = Path.GetDirectoryName(fullZipToPath); + + if (directoryName.Length > 0) + Directory.CreateDirectory(directoryName); + + using (FileStream streamWriter = File.Create(fullZipToPath)) + { + StreamUtils.Copy(zipStream, streamWriter, buffer); + } + } + + progressBar.Value++; + } + } + MessageBox.Show("Extraction complete!", "smolZIP", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + progressBar.Value = 0; + } + } + + // Create ZIP File with progress + private void CreateZip(string folderPath, string zipFilePath) + { + try + { + FastZipEvents events = new FastZipEvents(); + events.Progress = new ProgressHandler((source, progress) => + { + progressBar.Value = progressBar.Value + 1; + }); + + FastZip fastZip = new FastZip(events); + fastZip.CreateZip(zipFilePath, folderPath, true, null); + MessageBox.Show("Archiving complete!", "smolZIP", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show($"An error occurred: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + progressBar.Value = 0; + } + } + + private void btnExtractZip_Click(object sender, EventArgs e) + { + using (OpenFileDialog openFileDialog = new OpenFileDialog()) + { + openFileDialog.Filter = "Zip files (*.zip)|*.zip"; + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) + { + if (folderBrowserDialog.ShowDialog() == DialogResult.OK) + { + ExtractZip(openFileDialog.FileName, folderBrowserDialog.SelectedPath); + } + } + } + } + } + + private void btnCreateZip_Click(object sender, EventArgs e) + { + using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) + { + if (folderBrowserDialog.ShowDialog() == DialogResult.OK) + { + using (SaveFileDialog saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "Zip files (*.zip)|*.zip"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + CreateZip(folderBrowserDialog.SelectedPath, saveFileDialog.FileName); + } + } + } + } + } + + private void lblTitle_Click(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/smolZIP/MainForm.resx b/smolZIP/MainForm.resx new file mode 100644 index 0000000..7080a7d --- /dev/null +++ b/smolZIP/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/smolZIP/Program.cs b/smolZIP/Program.cs new file mode 100644 index 0000000..a78daee --- /dev/null +++ b/smolZIP/Program.cs @@ -0,0 +1,16 @@ +using System; +using System.Windows.Forms; + +namespace smolZIP +{ + static class Program + { + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} \ No newline at end of file diff --git a/smolZIP/Properties/AssemblyInfo.cs b/smolZIP/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..facdc82 --- /dev/null +++ b/smolZIP/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("smolZIP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("smolZIP")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("26aa0e0d-d336-47bb-b7b1-7bb383318507")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/smolZIP/Properties/Resources.Designer.cs b/smolZIP/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b711cf1 --- /dev/null +++ b/smolZIP/Properties/Resources.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace smolZIP.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("smolZIP.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap background1 { + get { + object obj = ResourceManager.GetObject("background1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/smolZIP/Properties/Resources.resx b/smolZIP/Properties/Resources.resx new file mode 100644 index 0000000..433b504 --- /dev/null +++ b/smolZIP/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\background1.jpg;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/smolZIP/Properties/Settings.Designer.cs b/smolZIP/Properties/Settings.Designer.cs new file mode 100644 index 0000000..572852f --- /dev/null +++ b/smolZIP/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace smolZIP.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/smolZIP/Properties/Settings.settings b/smolZIP/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/smolZIP/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/smolZIP/Resources/background1.jpg b/smolZIP/Resources/background1.jpg new file mode 100644 index 0000000..db37eaa Binary files /dev/null and b/smolZIP/Resources/background1.jpg differ diff --git a/smolZIP/packages.config b/smolZIP/packages.config new file mode 100644 index 0000000..27f7a28 --- /dev/null +++ b/smolZIP/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/smolZIP/smolZIP.csproj b/smolZIP/smolZIP.csproj new file mode 100644 index 0000000..4e61402 --- /dev/null +++ b/smolZIP/smolZIP.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {26AA0E0D-D336-47BB-B7B1-7BB383318507} + WinExe + smolZIP + smolZIP + v2.0 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\ICSharpCode.SharpZipLib.dll.0.85.4.369\lib\net20\ICSharpCode.SharpZipLib.dll + + + ..\packages\SevenZip.19.0.0\lib\net20\SevenZip.dll + + + + + + + + + + + Form + + + MainForm.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file