Environment.SpecialFolder.LocalApplicationData does not work properly in windows 2003

P

Peter Strøiman

Hi.

I have a web application that needs to generate dynamic content and store it
on the harddisk.
In order to ease up the installation and configuration process, we chose to
create a folder under the current user's application data folder.

When I mean ease up the configuration process what I mean is that you can
install the web site using a normal msi file and then you don't have to mess
with directory security etc. after running the installation.

I use the following code to create and get the directory

internal static string CacheDir
{
get
{
string test = Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData );
if ( !Directory.Exists( test ) )
Directory.CreateDirectory( test );
test += "\\CompanyName";
if ( !Directory.Exists( test ) )
Directory.CreateDirectory( test );
return test;
}
}

On our windows 2000 test server, it creates the following path:
C:\Documents and Settings\MACHINENAME\ASPNET\Local Settings\Application
Data\COMPANYNAME

When installing and running the same application on a windows 2003 server, I
get the error message:

Path cannot be the empty string or all whitespace.
at System.IO.Directory.CreateDirectory(String path)

Can anybody tell me why?

Thanks in advance,
Peter Strøiman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top