Permissions problems using Chilkat Zip .NET in ASP.NET

Question:

When I create a Zip on the IIS web server (from an ASP.NET page), the user can’t download the file because it forces the NT authentication window, etc. since ASPNET (IUSR, etc.) does not have permissions.

Answer:

When writing a Zip, the Zip component creates the Zip in a temporary directory and if successful, moves it to the destination filename. The problem is that the file created inherits the permissions of the temporary directory, and when it is moved to the directory where you would like users to be able to access it, it is not possible because the permissions are maintained and do not get the permissions of the final directory. To fix this, set the TempDir property to the same directory as where the Zip will be created. For example:

			Chilkat.Zip zip = new Chilkat.Zip();

			zip.UnlockComponent("UnlockCode");

			zip.TempDir = "c:/Inetpub/wwwroot/TestChilkat/";

			zip.NewZip("c:/Inetpub/wwwroot/TestChilkat/test.zip");

			zip.AppendAnsi("test.txt","This is a test");

			zip.WriteZipAndClose();

			TextBox1.Text = zip.LastErrorText;