开发者

Visual Basic 2010 Picturebox1.Image ftp upload

开发者 https://www.devze.com 2023-01-14 17:11 出处:网络
can someone show me an example script of开发者_运维技巧 how I would upload picturebox1\'s Image to an FTP connection?This ought to do it with just plain .NET classes:

can someone show me an example script of开发者_运维技巧 how I would upload picturebox1's Image to an FTP connection?


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


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


                Dim username = "USERNAME"
                Dim password = "PASSWORD"
                Dim hostname = "http://www.wherethefilewillappear.com/directory1/"
                Dim server = "ftp://ftp.yoursite.com/"
                My.Computer.Network.UploadFile("C:\text.txt", server &"/text.txt", username, password)

Easy as that.

0

精彩评论

暂无评论...
验证码 换一张
取 消