How do I convert an absolute or relative URI path (e.g. /foo/bar.txt
) to a (segmentwise) corresponding relative file system path (e.g. foo\bar.txt
) in .NET?
My program is not an ASP.NET application.
How do I convert an absolute or relative URI path (e.g. /foo/bar.txt
) to a (segmentwise) corresponding relative file system path (e.g. foo\bar.txt
) in .NET?
My program is not an ASP.NET application.
Have you already tried
Server.MapPath
?or
Uri.LocalPath
property? Something like following :You can do this:
See MSDN for details
I figured out this way to produce a full absolute file system path from a relative or absolute URI and a base path.
With:
From a relative URI:
From an absolute URI: