Ash
Ash

Reputation: 477

Getting system Mydocument path using C#.net(Web based Application)

Am using C#.net(Web based) and Am trying to get Mydocument file path using following code

    Label1.Text = System.Environment.GetEnvironmentVariable("USERPROFILE") +"\\My Documents\\";
                 or
     Label1.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

while running using IDE .i got correct mydocument path . if i host my application i got different path rather getting mydocument path .

Please help me to find solution

Regrads, ash

Upvotes: 2

Views: 762

Answers (2)

TheLukeMcCarthy
TheLukeMcCarthy

Reputation: 2283

Why do you want the MyDocument path? If you are doing something with the web you should write to a directory you can clean out with a script that is run periodically.

Personally I would recommend something like

Server.MapPath("./temp")

The above will give you the full path to the "temp" directory inside of where the current aspx page is.

Upvotes: 0

Davide Piras
Davide Piras

Reputation: 44605

When the application runs on the server the user account under it executes is surely not your local user account.

This is by definition and it's actually ok, you should design your application in a way that it's independent from the name of the execution account on the server.

Upvotes: 1

Related Questions