Directory.Exists(Application["AppPath"])

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hello,

I want to check if an directory exist.
Directory.Exists(Application["AppPath"] + "/Uploads/")

I'm doing this inside a asp.net web project in a class file.

Here is the error message.
The name 'Application' does not exist in the class or namespace.

What kind of namespace do I have to include?
Or are there other options to get the application path?

Thanks!
 
if your accessing the Application object from a seperate class file not
inheriting from Page or UserControl
you need to reference it as System.Web.HttpAppliction["MyAppVar"]
 
The message that I get now is:
'System.Web.HttpApplication' denotes a 'class' where a 'variable' was
expected

When using this code:
System.Web.HttpApplication["AppPath"]



Why?



Ron Vecchi said:
if your accessing the Application object from a seperate class file not
inheriting from Page or UserControl
you need to reference it as System.Web.HttpAppliction["MyAppVar"]


Arjen said:
Hello,

I want to check if an directory exist.
Directory.Exists(Application["AppPath"] + "/Uploads/")

I'm doing this inside a asp.net web project in a class file.

Here is the error message.
The name 'Application' does not exist in the class or namespace.

What kind of namespace do I have to include?
Or are there other options to get the application path?

Thanks!
 
Back
Top