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.

1
  • 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: stackoverflow.com/a/23399048/3481183 Commented May 14, 2014 at 18:05

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.