Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Physical File Path

Tags:

c#

file-io

What is the best way to get the physical path to a file in C#?

UPDATE:

I have a file name but I don't want to hard code the path to it since it may change. I just know its relative path but not its physical path.

like image 264
LB. Avatar asked Nov 03 '09 05:11

LB.


People also ask

What is logical path and physical path in SAP?

Logical File name is nothing but file path at Operating system level. use transaction <FILE> to view logical file path. Physical File path is nothing but file path at application server level.

Where is logical file path in SAP?

Procedure. Procedure: In the SAP GUI, enter the transaction code FILE to open the Change View "Logical File Path Definition": Overview window. If a window opens with the message Caution: The table is cross-client. , press Enter.


1 Answers

For regular apps, Path.GetFullPath(path) will return this. If this is web, then MapPath is what you want (for example, Server.MapPath("~/foo/bar")).

Re comments; try HttpContext.Current.Server.MapPath(...); in the absense of HttpServerUtility (comments), then try VirtualPathUtility.ToAbsolute.

like image 159
Marc Gravell Avatar answered Nov 05 '22 17:11

Marc Gravell