189 8069 5689

vb.netftp上传,vb ftp上传

VB编写个程序上传文件到FTP

首先,在VB工具栏中添加部件Microsoft Internet Transfer Control 6.0 ,之后工具箱会多一个Inet的控件。

我们提供的服务有:网站设计制作、成都网站制作、微信公众号开发、网站优化、网站认证、新邵ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的新邵网站制作公司

拖放该控件到窗体上,设置控件中的属性

protocol : 2-icFTP

RemoteHost : 你的FTP服务IP或域名

RemotePort : 你的FTP端口

URL : 你的FTPURL地址

UserName和Password 这两个就不用说了

'窗体中添加一个文本框(text1)和一个按钮(Command1)代码如下:

Private Sub Command1_Click()

Dim isRight As Boolean

Dim filestr As String

filestr = app.path "\A"

Inet1.Execute "", "PUT " filestr " /A"

isRight = Inet1.StillExecuting '获取当前是否仍然在执行命令

Do While isRight

isRight = Inet1.StillExecuting

DoEvents

Loop

filestr = app.path "\B"

Inet1.Execute "", "PUT " filestr " /B"

isRight = Inet1.StillExecuting '获取当前是否仍然在执行命令

Do While isRight

isRight = Inet1.StillExecuting

DoEvents

Loop

filestr = app.path "\C"

Inet1.Execute "", "PUT " filestr " /C"

isRight = Inet1.StillExecuting '获取当前是否仍然在执行命令

Do While isRight

isRight = Inet1.StillExecuting

DoEvents

Loop

filestr = app.path "\D"

Inet1.Execute "", "PUT " filestr " /a/D"

isRight = Inet1.StillExecuting '获取当前是否仍然在执行命令

Do While isRight

isRight = Inet1.StillExecuting

DoEvents

Loop

End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)

text1.Text = text1.Text + CStr(State)

Select Case State

Case 11

text1.text ="在与主机通信的过程中发生了错误"

Case 12

text1.Text = "上传完成"

End Select

End Sub

vb.net ftp上传文件

Dim OpenFileDialog As New OpenFileDialog

OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments

OpenFileDialog.Filter = "文本文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"

If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then

Dim FileName As String = OpenFileDialog.FileName

' TODO: 在此处添加打开文件的代码。

textbox1.Text = FileName

End If

第一个按钮 上传

Dim filelast As String = fileaddbefore.Text.Substring(fileaddbefore.Text.LastIndexOf("."), fileaddbefore.Text.Length - fileaddbefore.Text.LastIndexOf("."))

MessageBox.Show(filelast)

My.Computer.Network.UploadFile(textbox1.Text, "" 文件名.Text filelast, "登录名1", "登录密码", True, 100)

第二个按钮

vb写ftp上传功能的疑问

net1.Protocol = icFTP

Inet1.RemoteHost = ServerName'服务器地址

Inet1.RemotePort = 21'FTP端口

Inet1.UserName = uName'用户名

Inet1.Password = uPWS'密码

下载文件:

Inet1.Execute "", "GET 1.txt d:\1.txt"

ri = Inet1.StillExecuting

Do While ri

ri = Inet1.StillExecuting

DoEvents

Loop

上传文件:

Inet1.Execute "", "PUT d:\1.txt 1.txt"

ri = Inet1.StillExecuting

Do While ri

ri = Inet1.StillExecuting

DoEvents

Loop

VB ftp如何成功上传文件

最简单的方法是用ftp批处理,代码如下

open app.path "\ftpcmd.ftp" for output as #1 '创建一个ftp命令文件

print #1, "open " "IP" '打开ftp服务器

print #1, "user " "用户名"

print #1, "pass " "密码"

print #1, "lcd " "本地文件路径" '指定本地文件所在目录

print #1, "put " "文件名"

close #1 'frp命令文件写完了

shell "ftp -n -s:" app.path "\ftpcmd.ftp" '调用系统ftp,并执行上面写的ftpcmd.ftp

ftp上传文件用vb.net怎么实现

My.Computer.Network.UploadFile(本地文件路径, ftp服务器路径包括文件名,用户名,密码)


新闻标题:vb.netftp上传,vb ftp上传
文章转载:http://cdxtjz.cn/article/hcjdid.html

其他资讯