URI formats are not supported Error RRS feed

  • Question

  • User-670838653 posted

    Hi All,

    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.


    Thursday, February 2, 2006 12:58 PM

All replies

  • User-1372641848 posted

    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


    Friday, February 3, 2006 1:25 PM
  • User1705226643 posted


    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
                Dim FileNameObj As System.IO.FileInfo = New System.IO.FileInfo(FilePath & "/" & lblFileName.Text)
                '  If FileName.Exists Then
                Response.AddHeader("Content-Disposition", "attachment; filename=" & FileNameObj.Name)
                Response.AddHeader("Content-Length", FileNameObj.Length.ToString())
                Response.ContentType = ReturnExtension(FileNameObj.Extension.ToLower()) 'For content type
                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.


    Tuesday, August 26, 2008 5:47 AM
  • User1740892710 posted


    hi, if you want to download a file from its better to go for webclient class in system.net.

     webclient client = new webclient()


    hope it helps you.

    Thursday, August 28, 2008 1:05 PM
  • User1705226643 posted

    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,



    Monday, September 1, 2008 3:28 AM
  • User1211441112 posted

    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)


    using System.Drawing;
    using System.IO;
    using System.Net;

    protected void Page_Load(object sender, EventArgs e)

    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);


    Tuesday, May 18, 2010 6:35 AM