Directory.Exists(Application["AppPath"])

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!
 
R

Ron Vecchi

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"]
 
A

Arjen

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!
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top