(c#) Create a Zip file from a Text file - NET Framework 3.5 ?

  • Thread starter Thread starter nextb88
  • Start date Start date
N

nextb88

Guest
I want to create a Zip file from a Text file using NET Framework 3.5.

I used the following code. And it works...
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;

private void ZIPToolStripMenuItem_Click(object sender, EventArgs e)
{
string path1 = @"E:\Folder1\Folder2\Text Document.txt";
string path2 = @"E:\Text Document.zip";
ZipFile z = ZipFile.Create(path2);
z.BeginUpdate();
z.Add(path1);
z.CommitUpdate();
z.Close();
}
But problem is when I open the Zip file, I have to open Folder1, then Folder2 ...Text Document.txt
I wish that when I open a Zip file, it only has a Text file inside.
Is it possible? If so, my question is how to do it ?
I ask for your help. Thanks in advance.


The result I don't want:

1.gif

The result I want, if possible:


2.gif

Continue reading...
 
Back
Top