开发者

Convert absolute path to clientrelative path

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜