12 Mar 2009

Resolve Virtual Path From Physical Path (ASP.NET)

Quick code snippet to help people who want to derive a Virtual (web) path from a Physical (file) path:

string strVirtualPath = VirtualPathUtility.ToAbsolute("~/" + strPhysicalPath.Replace(Request.PhysicalApplicationPath, "").Replace("\\", "/"));


VirtualPathUtility FTW!

No comments:

Post a Comment

Comments are very welcome unless you're a spammer, in which case you should probably kill yourself.

If I helped you out today, you can buy me a beer below. Cheers!