Click here to Skip to main content
15,900,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing project in c# 3.5.

I create the folder name (image) inside the project.
I want to find absolute path of image folder in c#3.5 like in asp.net server.mappath() method available.


Please help me
Posted
Updated 5-Sep-10 22:24pm
v2
Comments
Dalek Dave 6-Sep-10 4:24am    
Edited for Readability, Grammar and Syntax.

If you do a windows app you can do this.
You can do this on your serverside files in ASP.NET as well, only not with a messagebox.

//Get the Image folder from your projekt.
System.IO.DirectoryInfo DI = new System.IO.DirectoryInfo("Image");
            MessageBox.Show(DI.FullName);


With this you got power to use the folder as you want in code.
You can see creation time and Lastaccess and so on.
 
Share this answer
 
v2
Comments
Dalek Dave 6-Sep-10 4:25am    
Good Call.
Per Söderlund 6-Sep-10 5:31am    
Ty for voting.
Say, your image folder path is "\image" (Folder "image" is just inside the web application root folder)

Then, find the absolute physical path as follows :

string filePath = Server.MapPath("~/image");
 
Share this answer
 
Comments
amitthakkar1987 6-Sep-10 1:42am    
application is window based not a web application
Al-Farooque Shubho 6-Sep-10 2:39am    
Oh..then you should just use the following code:

string filePath = System.IO.Path.GetFullPath(relativePath);
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;


This will give you the exact path where the exe is located. On deploying usually the image folder will be included in the same directory as the exe
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900