开发者

Convert absolute path to clientrelative path

开发者 https://www.devze.com 2022-12-11 03:25 出处:网络
Using ASP.NET how can I convert a absolute path to a relative client path? Eg.: Today I have a address like that: \'c:\\web\\site\\im开发者_JAVA技巧ages\\somefile.some\' I want to convert to \"/site/

Using ASP.NET how can I convert a absolute path to a relative client path?

Eg.: Today I have a address like that: 'c:\web\site\im开发者_JAVA技巧ages\somefile.some' I want to convert to "/site/images/somefile.some", It is worth to say that "site", "images" and somefile.some may change.


This Question will help you: Absolute path back to web-relative path

That said, why are you using an absolute path rather than the ~/ which is suggested?

For example, if you use "~/images/somefile.some" and pass it to the [Control].ResolveUrl(url as string) method, then it would translate that into the path for somefile.some based on the root of the directory.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号