locked
URI formats are not supported Error RRS feed

  • Question

  • User-670838653 posted

    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.

     

    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

    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  

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

    client.download("dst","src").

    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,

     

    Ajit 

    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)

    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

    Tuesday, May 18, 2010 6:35 AM