I am generating a zip file from the folder
D:\Nagaraj\Dotnet\Zipfile\Zipfile\Filebuild\Hi
. There are 2 txt files within the folder.
But problem is that within the zip file there is the path D:\Nagaraj\Dotnet\Zipfile\Zipfile\Filebuild\Hi
and within that folder are the 2 txt files.
Now I need to remove the path D:\Nagaraj\Dotnet\Zipfile\Zipfile\Filebuild\Hi
and directly generate the Hi.zip
with the 2 txt file in the root of the archive. I'm using SharpZipLib for creating the archive.
protected void Page_Load(object sender, EventArgs e)
{
StartZip("D:/Nagaraj/Dotnet/Zipfile/Zipfile/Filebuild/Hi",".zip");
}
public void StartZip(string directory, string zipFileName)
{
ZipFile z = ZipFile.Create(directory + zipFileName);
z.BeginUpdate();
string[] filenames = Directory.GetFiles(directory);
foreach (string filename in filenames)
{
z.Add(filename);
}
z.CommitUpdate();
z.Close();
}