MapPath function is commonly used in Asp.net. But if you want to used in other projects like DLL project, User difined control, you should reference System.Web namespace and call HttpContext.Current.Server.MapPath. HttpServerUtility does not support it. eg: string filepath = "~/Upload/test.jpg"; HttpContext.Current.Server.MapPath(filepath);