// 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.
None
0 Points
4 Posts
URI formats are not supported Error
Feb 02, 2006 12:58 PM|georgemacy|LINK
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.
Thanks in advance.
Member
191 Points
935 Posts
Re: URI formats are not supported Error
Feb 03, 2006 01:25 PM|Jigar|LINK
m_image_path should be path to the file on your filesystem, you are passing URL which is not supported by FileStream.
Check FileStream Constructor
-----------------------
Do not forget to "Mark as Answer" on the post that helped you.
None
0 Points
5 Posts
Re: URI formats are not supported Error
Aug 26, 2008 05:47 AM|ajit2mail@gmail.com|LINK
Hi,
I dnt know how post to start new thread here. But hope any one can solve it.
My problem is i am providing link to download a file using link button <asp:link1 runat="server" text="Download" />
And in code behind i had :
Dim FilePath As String = FileHosting.Static.GenericCode.CreateDownloadLink() & lblUserId.Text & "/" & lblGroup.Text
Try
Dim FileNameObj As System.IO.FileInfo = New System.IO.FileInfo(FilePath & "/" & lblFileName.Text)
' If FileName.Exists Then
ViewState.Clear()
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & FileNameObj.Name)
Response.AddHeader("Content-Length", FileNameObj.Length.ToString())
Response.ContentType = ReturnExtension(FileNameObj.Extension.ToLower()) 'For content type
Response.WriteFile(FileNameObj.FullName)
Response.End()
lblFileDescription.Text = "Download done successfully~~"
Catch ex As Exception
lblFileDescription.Text = ex.Message & FilePath & "/" & lblFileName.Text
End Try
Working fine in local machine but when i am uploading on liver server i m getting error:
URI formats are not supported.
Please help me.
Thnks
HCF-8
Phase - 3B2
Mohali,
Punjab
Member
21 Points
68 Posts
Re: URI formats are not supported Error
Aug 28, 2008 01:05 PM|satya.ambatipudi|LINK
hi, if you want to download a file from its better to go for webclient class in system.net.
webclient client = new webclient()
client.download("dst","src").
hope it helps you.
None
0 Points
5 Posts
Re: URI formats are not supported Error
Sep 01, 2008 03:28 AM|ajit2mail@gmail.com|LINK
Hi, Thank you for responce.
I am not going to upload the file. I am going to provide a link so that user can download the file.
Thank you,
Ajit
HCF-8
Phase - 3B2
Mohali,
Punjab
Contributor
4392 Points
933 Posts
Re: URI formats are not supported Error
May 18, 2010 06:35 AM|Vipindas|LINK
The WebClient class provides common methods for sending data to or receiving data from any local, intranet, or Internet resource identified by a URI.
WebClient.DownloadFile(Uri, String)
Or,
using System.Drawing;
using System.IO;
using System.Net;
protected void Page_Load(object sender, EventArgs e)
{
GetImage("http://www.cssnz.org/flower.jpg");
}
private static void GetImage(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.Accept = "image/gif";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream s = response.GetResponseStream();
Bitmap bmp = new Bitmap(s);
}
http://www.west-wind.com/presentations/dotnetwebrequest/dotnetwebrequest.htm