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

  • Thread starter Thread starter Peter Strøiman
  • Start date Start date
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
 
Back
Top