URI formats are not supported

M

msnews

Hi All,

Requirement
To get an image from web server A, resize the image and then save it at our
web server B (our server).


//--------------------------------------------------------------------
string m_image_path = "http://www.abc.com/image/1234.jpg"; //sample
filename
Image m_src_image;

// Wrap the FileStream in a "using" directive, to ensure the handle
// gets closed when the object goes out of scope
using(Stream stream = new FileStream(m_image_path, FileMode.Open))
m_src_image = Image.FromStream(stream);

//and i have some more code after that...
//--------------------------------------------------------------------


I am getting the following exceptiong at FileMode.Open place
Exception Details: System.ArgumentException: URI formats are not supported.


Please help me. How to solve this. Sample code will help.


Note.
I am trying to follow the code at devx website
http://www.devx.com/dotnet/article/22079/1763/page/1


Thanks in advance.
 
J

Joerg Jooss

Hello msnews,
Hi All,

Requirement
To get an image from web server A, resize the image and then save it
at our
web server B (our server).
//--------------------------------------------------------------------
string m_image_path = "http://www.abc.com/image/1234.jpg"; //sample
filename
Image m_src_image;
// Wrap the FileStream in a "using" directive, to ensure the handle
// gets closed when the object goes out of scope
using(Stream stream = new FileStream(m_image_path, FileMode.Open))
m_src_image = Image.FromStream(stream);
//and i have some more code after that...
//--------------------------------------------------------------------
I am getting the following exceptiong at FileMode.Open place Exception
Details: System.ArgumentException: URI formats are not supported.

Please help me. How to solve this. Sample code will help.

You cannot use a FileStream to open a resource referenced by HTTP. You must
use System.Net.WebClient or System.Net.HttpWebRequest to obtain a network
stream instead.

WebClient webclient = new WebClient();
using(Stream stream = webClient.OpenRead(imageUrl)) {
// Process image...
}

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top