can someone show me an example script of how I would upload picturebox1's Image to an FTP connection?
A:
Sounds like your PictureBox
has a source that's an image on disk. If it's not, find a way to save that image to disk.
Use this VB.NET FTP client library to upload that image to your FTP destination. It wraps all the logic needed, and will save you the time of writing the code yourself.
It uses System.Net.FtpWebRequest
.
myFtp.Upload("C:\myimage.png", "/pub/someImage.png")
p.campbell
2010-09-05 05:15:49
there is no source, its a screen shot.Im trying to upload a captured screenshot to an ftp.Do i need to make a temporary save first?
Joseph
2010-09-05 05:21:40
+1
A:
This ought to do it with just plain .NET classes:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using ms As New System.IO.MemoryStream
PictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
Using wc As New System.Net.WebClient
wc.UploadData("ftp://foo.com/bar/mumble.png", ms.ToArray())
End Using
End Using
End Sub
Hans Passant
2010-09-05 05:28:24