Compress and Decompress File


C# windows Application to compress and decompress files. Please find the code below.

Form1.cs


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.IO.Compression;

namespace CompressFile
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public void compress()
{
string fileToBeCompressed = OpenFileDia.FileName;
string zipFilename = "D:\\dk.zip";
using (FileStream target = new FileStream(zipFilename, FileMode.Create, FileAccess.Write))
using (GZipStream alg = new GZipStream(target, CompressionMode.Compress))
{
byte[] data = File.ReadAllBytes(fileToBeCompressed);
alg.Write(data, 0, data.Length);
alg.Flush();
}
}
public void Decompress()
{
string compressedFile = OpentoDec.FileName;
string originalFileName = "D:\\dk.xls";
using (FileStream zipFile = new FileStream(compressedFile, FileMode.Open, FileAccess.Read))
using (FileStream originalFile = new FileStream(originalFileName, FileMode.Create, FileAccess.Write))
using (GZipStream alg = new GZipStream(zipFile, CompressionMode.Decompress))
{
while (true)
{
// Reading 100bytes by 100bytes
byte[] buffer = new byte[100];
// The Read() method returns the number of bytes read
int bytesRead = alg.Read(buffer, 0, buffer.Length);

originalFile.Write(buffer, 0, bytesRead);
if (bytesRead != buffer.Length)
break;
}
}
}

private void button1_Click(object sender, EventArgs e)
{
compress();

MessageBox.Show("Compressed successfully");
}

private void button2_Click(object sender, EventArgs e)
{
Decompress();
MessageBox.Show("De-Compressed successfully");
}

private void button3_Click(object sender, EventArgs e)
{
OpenFileDia.Title = "Dharmendra -- Choose File to Compress";
OpenFileDia.FileName = "";
OpenFileDia.Filter = "Excel Files|*.xls|Document Files|*.doc|Image Files|*.jpg|PDF Files|*.pdf";
OpenFileDia.ShowDialog();
}

private void button4_Click(object sender, EventArgs e)
{
OpentoDec.ShowDialog();
}

private void button5_Click(object sender, EventArgs e)
{
Form2 frmText = new Form2();
frmText.Show();
this.Hide();
}
}
}



Form1.Designer.cs

namespace CompressFile
{
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///

/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.OpenFileDia = new System.Windows.Forms.OpenFileDialog();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.OpentoDec = new System.Windows.Forms.OpenFileDialog();
this.saveZipFile = new System.Windows.Forms.SaveFileDialog();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(117, 25);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(94, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Compress File";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(117, 67);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(94, 28);
this.button2.TabIndex = 1;
this.button2.Text = "De-Compress";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// OpenFileDia
//
this.OpenFileDia.FileName = "openFileDialog1";
this.OpenFileDia.InitialDirectory = "D:";
//
// button3
//
this.button3.Location = new System.Drawing.Point(12, 25);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 2;
this.button3.Text = "Choose File";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(12, 72);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 3;
this.button4.Text = "Choose File";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// OpentoDec
//
this.OpentoDec.Filter = "Zip Files|*.zip|win rar files|*.rar";
this.OpentoDec.InitialDirectory = "D:";
this.OpentoDec.Title = "Dharmendra--Choose File to Decompress";
//
// saveZipFile
//
this.saveZipFile.Title = "Dharmendra--Save Zipped File";
//
// button5
//
this.button5.Location = new System.Drawing.Point(288, 25);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 4;
this.button5.Text = "Open Note Pad";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(658, 426);
this.Controls.Add(this.button5);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.OpenFileDialog OpenFileDia;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.OpenFileDialog OpentoDec;
private System.Windows.Forms.SaveFileDialog saveZipFile;
private System.Windows.Forms.Button button5;
}
}



Form2.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CompressFile
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{


}

private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
{
this.Close();
}

private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
// openTXTfile.ShowDialog();
string Chosen_File = "";
if (openTXTfile.ShowDialog() != DialogResult.Cancel)
{
Chosen_File = openTXTfile.FileName;
txtContent.LoadFile(Chosen_File, RichTextBoxStreamType.PlainText);
}
}

private void saveAsToolStripMenuItem1_Click(object sender, EventArgs e)
{
string saveFile = "";
if (saveTXTfile.ShowDialog() != DialogResult.Cancel)
{
saveFile = saveTXTfile.FileName;
txtContent.SaveFile(saveFile, RichTextBoxStreamType.PlainText);
}
}

private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
string saveFile = openTXTfile.FileName;
if (!string.IsNullOrEmpty(saveFile))
{
txtContent.SaveFile(saveFile, RichTextBoxStreamType.PlainText);
}
else
{
saveFile = saveTXTfile.FileName;
if (saveTXTfile.ShowDialog() != DialogResult.Cancel)
{
txtContent.SaveFile(saveFile, RichTextBoxStreamType.PlainText);
}
}
}

private void goToToolStripMenuItem_Click(object sender, EventArgs e)
{

}

private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();

pageSetforPrint.AllowMargins = true;
pageSetforPrint.AllowOrientation = true;
pageSetforPrint.AllowPaper = true;
pageSetforPrint.AllowPrinter = true;

pageSetforPrint.ShowHelp = true;
pageSetforPrint.ShowNetwork = true;
pageSetforPrint.Document = pd;

pageSetforPrint.ShowDialog();
}

private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
printDocument1.DocumentName = txtContent.Text;
PrintPreviewDialog pp = new PrintPreviewDialog();
System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
pp.Document = pd;
pp.ShowDialog();
}
}
}


Form2.Designer.cs

namespace CompressFile
{
partial class Form2
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///

/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.txtContent = new System.Windows.Forms.RichTextBox();
this.openTXTfile = new System.Windows.Forms.OpenFileDialog();
this.saveTXTfile = new System.Windows.Forms.SaveFileDialog();
this.newFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.pageSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.undoToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.findNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.goToToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.timeDateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.formatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wordWrapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusBarToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpTopicsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutDKTextEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.pageSetforPrint = new System.Windows.Forms.PageSetupDialog();
this.printDocument1 = new System.Drawing.Printing.PrintDocument();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.editToolStripMenuItem,
this.formatToolStripMenuItem,
this.viewToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(686, 24);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newFileToolStripMenuItem,
this.openToolStripMenuItem,
this.saveToolStripMenuItem1,
this.saveAsToolStripMenuItem1,
this.toolStripSeparator1,
this.pageSetupToolStripMenuItem,
this.printToolStripMenuItem,
this.toolStripSeparator2,
this.exitToolStripMenuItem1});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
this.fileToolStripMenuItem.Text = "File";
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// saveToolStripMenuItem1
//
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.saveToolStripMenuItem1.Text = "Save";
this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click);
//
// saveAsToolStripMenuItem1
//
this.saveAsToolStripMenuItem1.Name = "saveAsToolStripMenuItem1";
this.saveAsToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.saveAsToolStripMenuItem1.Text = "Save As";
this.saveAsToolStripMenuItem1.Click += new System.EventHandler(this.saveAsToolStripMenuItem1_Click);
//
// exitToolStripMenuItem1
//
this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1";
this.exitToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.exitToolStripMenuItem1.Text = "Exit";
this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitToolStripMenuItem1_Click);
//
// editToolStripMenuItem
//
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.undoToolStripMenuItem1,
this.toolStripSeparator3,
this.cutToolStripMenuItem,
this.copyToolStripMenuItem,
this.pasteToolStripMenuItem,
this.deleteToolStripMenuItem,
this.toolStripSeparator4,
this.findToolStripMenuItem,
this.findNextToolStripMenuItem,
this.replaceToolStripMenuItem,
this.goToToolStripMenuItem,
this.undoToolStripMenuItem,
this.selectAllToolStripMenuItem,
this.timeDateToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.editToolStripMenuItem.Text = "Edit";
//
// cutToolStripMenuItem
//
this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
this.cutToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.cutToolStripMenuItem.Text = "Cut";
//
// copyToolStripMenuItem
//
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.copyToolStripMenuItem.Text = "Copy";
//
// pasteToolStripMenuItem
//
this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.pasteToolStripMenuItem.Text = "Paste";
//
// selectAllToolStripMenuItem
//
this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.selectAllToolStripMenuItem.Text = "Select All";
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.helpTopicsToolStripMenuItem,
this.toolStripSeparator5,
this.aboutDKTextEditorToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
this.helpToolStripMenuItem.Text = "Help";
//
// txtContent
//
this.txtContent.Location = new System.Drawing.Point(0, 27);
this.txtContent.Name = "txtContent";
this.txtContent.Size = new System.Drawing.Size(686, 504);
this.txtContent.TabIndex = 2;
this.txtContent.Text = "";
//
// openTXTfile
//
this.openTXTfile.Filter = "Text Files|*.txt";
this.openTXTfile.InitialDirectory = "C:";
this.openTXTfile.ShowHelp = true;
this.openTXTfile.SupportMultiDottedExtensions = true;
this.openTXTfile.Title = "DK-Open Text File";
//
// saveTXTfile
//
this.saveTXTfile.FileName = "New Text Document.txt";
this.saveTXTfile.Filter = "Text Files|*.txt";
//
// newFileToolStripMenuItem
//
this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem";
this.newFileToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newFileToolStripMenuItem.Text = "New File";
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
//
// pageSetupToolStripMenuItem
//
this.pageSetupToolStripMenuItem.Name = "pageSetupToolStripMenuItem";
this.pageSetupToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.pageSetupToolStripMenuItem.Text = "Page Setup";
this.pageSetupToolStripMenuItem.Click += new System.EventHandler(this.pageSetupToolStripMenuItem_Click);
//
// printToolStripMenuItem
//
this.printToolStripMenuItem.Name = "printToolStripMenuItem";
this.printToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.printToolStripMenuItem.Text = "Print";
this.printToolStripMenuItem.Click += new System.EventHandler(this.printToolStripMenuItem_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(149, 6);
//
// undoToolStripMenuItem
//
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
this.undoToolStripMenuItem.Size = new System.Drawing.Size(149, 6);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6);
//
// undoToolStripMenuItem1
//
this.undoToolStripMenuItem1.Name = "undoToolStripMenuItem1";
this.undoToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
this.undoToolStripMenuItem1.Text = "Undo";
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.deleteToolStripMenuItem.Text = "Delete";
//
// findToolStripMenuItem
//
this.findToolStripMenuItem.Name = "findToolStripMenuItem";
this.findToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.findToolStripMenuItem.Text = "Find ...";
//
// findNextToolStripMenuItem
//
this.findNextToolStripMenuItem.Name = "findNextToolStripMenuItem";
this.findNextToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.findNextToolStripMenuItem.Text = "Find Next ";
//
// replaceToolStripMenuItem
//
this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem";
this.replaceToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.replaceToolStripMenuItem.Text = "Replace...";
//
// goToToolStripMenuItem
//
this.goToToolStripMenuItem.Name = "goToToolStripMenuItem";
this.goToToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.goToToolStripMenuItem.Text = "Go To ...";
this.goToToolStripMenuItem.Click += new System.EventHandler(this.goToToolStripMenuItem_Click);
//
// timeDateToolStripMenuItem
//
this.timeDateToolStripMenuItem.Name = "timeDateToolStripMenuItem";
this.timeDateToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.timeDateToolStripMenuItem.Text = "Time/Date";
//
// formatToolStripMenuItem
//
this.formatToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.wordWrapToolStripMenuItem,
this.fontToolStripMenuItem});
this.formatToolStripMenuItem.Name = "formatToolStripMenuItem";
this.formatToolStripMenuItem.Size = new System.Drawing.Size(53, 20);
this.formatToolStripMenuItem.Text = "Format";
//
// wordWrapToolStripMenuItem
//
this.wordWrapToolStripMenuItem.Name = "wordWrapToolStripMenuItem";
this.wordWrapToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.wordWrapToolStripMenuItem.Text = "Word Wrap";
//
// fontToolStripMenuItem
//
this.fontToolStripMenuItem.Name = "fontToolStripMenuItem";
this.fontToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.fontToolStripMenuItem.Text = "Font...";
//
// viewToolStripMenuItem
//
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statusBarToolStripMenuItem});
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(41, 20);
this.viewToolStripMenuItem.Text = "View";
//
// statusBarToolStripMenuItem
//
this.statusBarToolStripMenuItem.Name = "statusBarToolStripMenuItem";
this.statusBarToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.statusBarToolStripMenuItem.Text = "Status Bar";
//
// helpTopicsToolStripMenuItem
//
this.helpTopicsToolStripMenuItem.Name = "helpTopicsToolStripMenuItem";
this.helpTopicsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.helpTopicsToolStripMenuItem.Text = "Help Topics";
//
// aboutDKTextEditorToolStripMenuItem
//
this.aboutDKTextEditorToolStripMenuItem.Name = "aboutDKTextEditorToolStripMenuItem";
this.aboutDKTextEditorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.aboutDKTextEditorToolStripMenuItem.Text = "About DKTextEditor";
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6);
//
// printDocument1
//
this.printDocument1.OriginAtMargins = true;
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(686, 528);
this.Controls.Add(this.txtContent);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.RichTextBox txtContent;
private System.Windows.Forms.OpenFileDialog openTXTfile;
private System.Windows.Forms.SaveFileDialog saveTXTfile;
private System.Windows.Forms.ToolStripMenuItem newFileToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem pageSetupToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem printToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem findToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem findNextToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem goToToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator undoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem timeDateToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem formatToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem wordWrapToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fontToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem statusBarToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpTopicsToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripMenuItem aboutDKTextEditorToolStripMenuItem;
private System.Windows.Forms.PageSetupDialog pageSetforPrint;
private System.Drawing.Printing.PrintDocument printDocument1;
}
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace CompressFile
{
static class Program
{
///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}


Comments

Guest Author: kalpana20 Jul 2013

Please attach the form design with the code so it'll be useful



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: