2

Possible Duplicate:
Path.Combine for Urls?

I have a root directory like http://localhost/

I have a file name call sample.jpg

when I use Path.Combine(root, file), I get something like http://localhost\sample.jpg, I am wondering if I can get http://localhost/sample.jpg.

Community
  • 1
  • 1
user496949
  • 83,087
  • 147
  • 309
  • 426
  • Indeed, there are many implications when you combine url parts such as encoding, escaping, query string, virtual path being truncated. Should you need a more comprehensive solution, you can check out this answer: http://stackoverflow.com/a/23399048/3481183 – Believe2014 May 14 '14 at 18:05

1 Answers1

3

Path.Combine is designed for file system paths, not URLs, so I don't think it will give you what you desire in this case. You can always do the Path.Combine, followed by a String.Replace("\", "/") to correct your URL.

SqlRyan
  • 33,116
  • 33
  • 114
  • 199