Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

October 19, 2007

ASP.NET Current Working Directory is C:\WINDOWS\system32

You should never use relative directory paths in ASP.NET because the default current working directory of an ASP.NET process is typically c:\Windows\system32. Run this code to see it:

<%@ Page Language="C#" %>
<html>
<head>
<title>ASP.NET Hello World</title>
</head>
<body bgcolor="#FFFFFF">
<p>
<%
	Response.Write(System.IO.Directory.GetCurrentDirectory());
%>
</p>
</body>
</html>

You should use Server.MapPath or an absolute directory path.

This applies to any directory path passed to a Chilkat method. For example, if you do this:

...
	Chilkat.Zip zip = new Chilkat.Zip();
...
	zip.AppendFiles("myDirTree/*",true);
...

you’d be trying to add files from C:\Windows\system32\myDirTree\* — and that probably wont work…

This is probably what you want:

...
	Chilkat.Zip zip = new Chilkat.Zip();
...
	zip.AppendFiles(Server.MapPath("myDirTree/*"),true);
...


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.