0

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?

Brian Hooper
  • 21,544
  • 24
  • 88
  • 139
  • Check out this previous answer: http://stackoverflow.com/questions/5233735/how-to-get-asp-net-application-path – Lloyd Aug 25 '11 at 13:19

2 Answers2

4

Try this:

Server.MapPath("files")
Chandu
  • 81,493
  • 19
  • 133
  • 134
  • Thanks for your suggestion, but it doesn't compile. I'm not the only person to have this problem (see [this question](http://stackoverflow.com/questions/1518976/server-mappath)), and as the AppDomain method appears to be working I have done that. – Brian Hooper Aug 25 '11 at 13:54
3

There are a couple different ways

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

or

Server.MapPath(@"\files\")
zeal
  • 740
  • 1
  • 4
  • 31