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,503
  • 28
  • 40
skhurams
  • 2,083
  • 7
  • 43
  • 80

1 Answers1

2

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
  • 49,011
  • 11
  • 81
  • 108