我在文件系统监视器的FileSystemWatcher_Changed中加了对发生变化文件的处理事件
问题是:对发生改变的文件进行本地拷贝,是可以的,但把发生变化的文件拷贝到网络机器上就有问题,请大家帮忙分析一下,谢谢!
Private Sub FileSystemWatcher1_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
Dim source_file As String = "c:\dat\" + e.Name
Dim target_file As String = "\\192.168.168.6\c$\" + e.Name
Dim options As ConnectionOptions = New ConnectionOptions
options.Username = "administrator"
options.Password = "123456"
Dim scope As ManagementScope = New ManagementScope("\\192.168.168.6\root\cimv2", options)
Try
If scope.IsConnected Then
scope.Connect()
End If
Dim disk As ManagementObject = New ManagementObject(scope, New ManagementPath("Win32_LogicalDisk='c:'"), Nothing)
disk.Get()
File.Copy(source_file,target_file,True)
Catch ex As Exception
End Try
end sub
问题是:对发生改变的文件进行本地拷贝,是可以的,但把发生变化的文件拷贝到网络机器上就有问题,请大家帮忙分析一下,谢谢!
Private Sub FileSystemWatcher1_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
Dim source_file As String = "c:\dat\" + e.Name
Dim target_file As String = "\\192.168.168.6\c$\" + e.Name
Dim options As ConnectionOptions = New ConnectionOptions
options.Username = "administrator"
options.Password = "123456"
Dim scope As ManagementScope = New ManagementScope("\\192.168.168.6\root\cimv2", options)
Try
If scope.IsConnected Then
scope.Connect()
End If
Dim disk As ManagementObject = New ManagementObject(scope, New ManagementPath("Win32_LogicalDisk='c:'"), Nothing)
disk.Get()
File.Copy(source_file,target_file,True)
Catch ex As Exception
End Try
end sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货