tags:

views:

49

answers:

3

Hello,

I have an asp.net app and I am trying to save a text file to a folder that changes with each client. How can I write it to save the files to a folder that changes. For example one customer might be C:\inetpub\wwwroot\site1\ another might be C:\inetpub\wwwroot\site2. Relative paths don't seem to work, and I've tried GetCurrentDirectory but it kept giving me the wrong directory.

Thanks

A: 

Take a look at Path.GetDirectoryName(Request.ServerVariables("SCRIPT_NAME")).

Ben Alpert
That doesn't guarantee that is the folder location at the client though. There was no indication of whether or not it would be in a folder that represents the client's site.
casperOne
A: 

You should add a value to the web.config file which is set to the path where the file is saved.

Then, in you code, retrieve this value from the documentation, and use that path when saving.

casperOne
+1  A: 

You should try :

In the *.aspx.cs file :

string currentPath = Server.MapPath("~");

I don't have the tools to test here, but I think the code is right.

Julien N