Creating files from ASP.NET (C# or VB.NET) can be a pain, with directory permissions getting in the way…
Here is a C# example that shows how to create a .zip file in a "ZipFiles" subdirectory beneath the application root. You’ll first need to create the directory and then give it Write permission. Once you do it, the following code should work:
private string MappedApplicationPath()
{
string APP_PATH = System.Web.HttpContext.Current.Request.ApplicationPath.ToLower();
if (APP_PATH == "/") //a site
APP_PATH = "/";
else if (!APP_PATH.EndsWith(@"/")) //a virtual
APP_PATH += @"/";
string it = System.Web.HttpContext.Current.Server.MapPath(APP_PATH);
if (!it.EndsWith(@"\"))
it += @"\";
return it;
}
// This example creates a Zip file in a "ZipFiles" directory under
// the application root directory. You should first provide write access
// to the ZipFiles directory before running this sample.
protected void Button1_Click(object sender, EventArgs e)
{
Chilkat.Zip zip = new Chilkat.Zip();
zip.UnlockComponent("anything for 30-day trial");
string mappedPath = MappedApplicationPath();
zip.TempDir = mappedPath + "ZipFiles";
zip.NewZip(mappedPath + "ZipFiles\\test.zip");
zip.AppendAnsi("test.txt", "this is a test");
zip.WriteZipAndClose();
TextBox1.Text = zip.LastErrorText;
}