Brian Hooper
Brian Hooper

Reputation: 22084

How to find a directory in ASP.NET

I'm working on an Intranet web application on a server somewhere, and I wish that application to generate files so I can download them to my local PC.

I connect to this application using a URL in the browser like this...

http://myapp.ourplace.com

and I can get to the software using an ftp connection...

ftp://myapp.ourplace.com

where I can see a directory structure like this...

myapp.ourplace.com
    aspnet_client
    bin
    files
    images
    UserControls
    default.aspx
    myapp.bin
    .
    .
    .

I need to know how the C# application can locate the directory files in the above structure in order to write files into it. I've tried Environment.CurrentDirectory() + "\\files" but that doesn't appear to be the same place; no files appear in it at any rate.

Does anyone know how to do this?

Upvotes: 0

Views: 223

Answers (2)

zeal
zeal

Reputation: 740

There are a couple different ways

AppDomain.CurrentDomain.BaseDirectory + @"\files\"

or

Server.MapPath(@"\files\")

Upvotes: 3

Chandu
Chandu

Reputation: 82943

Try this:

Server.MapPath("files")

Upvotes: 4

Related Questions