Following is the code. When i m execuing it on the local host its working fine. But when i xecute it on IIS it giving the exception "System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\wwwroot\CorpNet\RestoreTemp\' is denied. " RestoreTemp is the directory which i m creating. CorpNet is the website name.
public static void UnzipIT(string sFileName, string sDirName)
{
ZipInputStream s = new ZipInputStream(File.OpenRead(sFileName));
ZipEntry theEntry;
theEntry = s.GetNextEntry();
while (!((theEntry == null)))
{
string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);
Directory.CreateDirectory(sDirName); //Here the exception is coming...while
//running thr IIS..
FileStream sWriter;
sWriter = File.Create(sDirName + fileName);
int size = 2048;
byte[] data = new byte[2049];
while ((true))
{
size = s.Read(data, 0, 2049);
if ((size > 0))
{
sWriter.Write(data, 0, size);
}
else
{
goto ex1;
}
}
ex1:
sWriter.Close();
theEntry = s.GetNextEntry();
}
s.Close();
}
Stack Trace:
[UnauthorizedAccessException: Access to the path 'C:\Inetpub\wwwroot\CorpNet\RestoreTemp\' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014275
System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) +2710272
System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) +150
System.IO.Directory.CreateDirectory(String path) +6
clsZip.UnzipIT(String sFileName, String sDirName) in c:\Inetpub\wwwroot\CorpNet\App_Code\clsZip.cs:37
RealTimeSelect.Button1_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\CorpNet\ArchiveSelect.aspx.cs:524
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
Kindly guide me.