0

I have an error in following code

Uri imagesrc = new Uri("http://somewebsite.com/demo/images/slideshow/29.jpg");
Image image = Image.FromFile(Path.Combine("/comph/", imagesrc.ToString()));

I have also tried following code - where /comph/ is my root directory

Image.FromFile(Path.Combine("/comph/","http://some_other_website.com/demo/images/slideshow/29.jpg");

The above image URL is correct when I paste this URL in browser it shows the image.

With the above code an exception is raised:

The given path's format is not supported.

What is wrong with this code ?

Michael Mairegger
  • 6,833
  • 28
  • 41
skhurams
  • 2,133
  • 7
  • 45
  • 82

1 Answers1

3

Path.Combine does not support urls.

You will have to translate the url to a (relative) file path first if you want to use Path.Combine

If you want to manipulate urls you can use the Url constructor that takes a base url and a relative url and combines them.

Emond
  • 50,210
  • 11
  • 84
  • 115