写这段帮助的时候,我意外发现Rename还可以移动文件。
例如将文件"jz.png"从photo目录移到到newkey目录:
Dim ftp1 As New FtpClient
ftp1.Host="196.128.143.28"
ftp1.Account = "foxuser"
ftp1.Password = "138238110"
If ftp1.Rename("\photo\jz.png","\newkey\jz.png") Then
Messagebox.show("移动文件成功!")
End If
GetFileList
用于返回FTP服务器指定目录下的全部文件名,以字符串集合的形式返回,语法:
GetFileList(Path)
Path:可选参数,用于指定目录,如果省略,则返回当前目录下的全部文件名。
示例
例如列出photo目录下的所有文件:
Dim ftp1 As New FtpClient
Dim fls As List(of String)
ftp1.Host="196.128.143.28"
ftp1.Account = "foxuser"
ftp1.Password = "138238110"
fls = ftp1.GetFileList(r("测试组名") & "/" & r("编号"))
For Each fl As String In fls
ftp1.Rename(r("测试组名") & "/" & r("编号") & "/" & fl,str1 & "/" & fl)
Output.Show(fl)
Next