写了一段代码,自己拿去改改吧
'删除文件
Dim t As String = ProjectPath & "\Publish\update.txt"
Dim z As String = ProjectPath & "\Publish\update.zip"
If FileSys.FileExists(t) Then
FileSys.DeleteFile(t,2,2)
End If
If FileSys.FileExists(z) Then
FileSys.DeleteFile(z,2,2)
End If
'创建update.txt
Dim s As String = Format(Date.Today,"yyy/M/d")
s = s.Replace("-","/")
Dim val As String = SpecialFolder.MyDocuments & "\update.txt"
FileSys.WriteAllText(val,s, False)
FileSys.MoveFile(SpecialFolder.MyDocuments & "\update.txt",t)
'创建update.zip
Dim zip As New zipFile
zip.Create(z)
zip.AddFolder(ProjectPath & "\Publish\project")
zip.Close()
'上传至ftp
Dim ftp1 As new ftpclient
ftp1.ShowUI = True
ftp1.host="ftp ip 地址"
ftp1.Account = "账号"
ftp1.password = "密码"
Dim ft As String = "/web/jinlun/update.txt"
Dim fz As String = "/web/jinlun/update.zip"
Dim fs As String() = {ft,fz}
For Each f As String In fs
If ftp1.FileExists(f) Then
ftp1.Delete(f)
End If
Next
ftp1.upload(t,ft,True) '上传
ftp1.upload(z,fz,True) '上传