0

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\images\somefile.some' I want to convert to "/site/images/somefile.some", It is worth to say that "site", "images" and somefile.some may change.

Cleiton
  • 17,663
  • 13
  • 46
  • 59

1 Answers1

2

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.

Community
  • 1
  • 1
Stephen Wrighton
  • 36,783
  • 6
  • 67
  • 86
  • I get this URL from an app.config, there is an application that salves the images files in webserve. – Cleiton Nov 05 '09 at 16:43