第三方用法自己学习参考:
https://docs.microsoft.com/zh-cn/dotnet/api/system.io.filesystemwatcher?view=netframework-4.8
试试
Public Sub OnRenamed(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs)
Dim wj As String = FileSys.GetName(e.FullPath)
Dim lj,mb As String
If wj.Contains(".xlsx") Then
Dim dr As DataRow = DataTables("bgffjl").SQLFind("[文件名] = '" & wj & "'")
If dr IsNot Nothing Then
If wj.Contains("测试报告") Then
mb = "测试报告"
Else
mb = "检测报告"
End If
lj = ProjectPath & "Excel\报告管理\" & mb & "\" & dr("wtdh") & "\" & wj
If CRCCheckFile(lj) <> dr("本地校验码") Then
If MessageBox.Show("【" & wj & "】报告已修改!是否同步至服务器?" & vbcrlf & "【是】 关闭文件并上传至服务器" & vbcrlf & "【否】 取消本次修改同步操作", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
ShowAppWindow(wj,5)
Dim ftp As new ftpclient
ftp.host="123123123"
ftp.Account = "123123"
ftp.password = "123123"
ftp.UTF8 = True
ftp.Upload(lj,"\报表生成文件\" & mb & "\" & dr("wtdh") & "\" & wj )
dr("本地校验码") = CRCCheckFile(lj)
dr("服务器校验码") = CRCCheckFile(lj)
dr.Save
End If
End If
End If
End If
End Sub