Hi. I've been working on this FTP client for a while and in it is Show selected image. I'm currently using this code:

 PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(ToolStripLabel1.Text)))

I added it to the Form load event. The picture I'm acquiring is from an FTP server but each time it loads i keep getting this error: The path is not of a legal form.
Is there a solution for this?
If so please give it to me :)

Thanks!

Recommended Answers

All 7 Replies

Try:

PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(New Uri(ToolStripLabel1.Text))))

Try:

PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(New Uri(ToolStripLabel1.Text))))

Gives me an error saying: Invalid URI: The URI is empty. < On Form Load event
and on button click event says 503 bad login.

Is there a way around it?

What string is in ToolStripLabel1.Text?

The only error I get when I use the url is a server error because the link doesn't contain username and password in order to log into the site.

 Function getimage(ByVal url As String) As Image
        Using w As New System.Net.WebClient
            w.Credentials = New System.Net.NetworkCredential(LoginMenu.TextBox1.Text, LoginMenu.TextBox2.Text)
            Using s As New IO.MemoryStream(w.DownloadData(url))
                Timer5.Start()
                Return Image.FromStream(s).Clone
            End Using
        End Using
    End Function

I'm actually using this one from one of my prevouis projects but i can't add the function to the Load event. It gives me "The path is not of a legal form." pointing to "Using s As New IO.MemoryStream(w.DownloadData(url))" but it works perfectly when the button gets clicked.

Any idea?

I can't seem to duplicate the error you describe. As long as the url is like what you posted then it goes to the server and stops because of failed log in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.