Getting relative virtual path from physical path

前端 未结 4 796
青春惊慌失措
青春惊慌失措 2020-11-29 04:50

How can I get the relative virtual path from the physical path in asp.net? The reverse method is like below:

Server.MapPath(\"Virtual Path Here\");
         


        
4条回答
  •  再見小時候
    2020-11-29 05:31

        public static string MapPathReverse(string fullServerPath)
        {            
            return @"~\" + fullServerPath.Replace(HttpContext.Current.Request.PhysicalApplicationPath,String.Empty);
        }
    

提交回复
热议问题