Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get full path of application directory

I have a website that is using ASP.NET and C#.

I am trying to do something like this

bitmap.Save(@"C:\Documents and Settings\Berzon\Desktop\Kinor\kWebGUI\Images\" + imageName + ".png")

But I dont want to have to write that whole path, since it changes from computer to computer.
How can I get the full path with C#? (this path is were the application is currently being saved)

like image 694
Ovi Avatar asked Dec 06 '22 20:12

Ovi


1 Answers

Use this:

bitmap.Save(System.IO.Path.Combine(Server.MapPath("~/RELATIVE PATH OF YOUR APPLICATION"), imageName + ".png"));

Or some of properties of HttpContext.Current.Request (ApplicationPath or AppDomain.CurrentDomain.BaseDirectory, for example)

like image 111
VMAtm Avatar answered Dec 11 '22 09:12

VMAtm