我遇到一种奇怪的情况,希望这里的人能解决。我已经为客户端编写了一个基于FileSystemWatcher的应用程序,并且在处理完每个文件之后,应将文件移动到一个好文件夹或坏文件夹中。问题是客户端使用的是AD,我无法在本地对其进行测试,而且显然必须存在某种未将权限报告回我的程序的权限问题,因此即使该文件删除了文件(下一个操作),复制失败。没有任何内容写入我的日志文件,因此没有生成异常。我已经使用映射的驱动器和UNC路径在本地测试了我的程序,它对我来说很好用。来源是VB.Net,但我认为这无关。
''' <summary>
''' Moves a file to one of two folders by overwriting the destination and deleting the source
''' </summary>
''' <param name="name">Full path of filename</param>
''' <param name="good">Whether file is moved to good or bad folder</param>
''' <remarks>good should only be true if data was successfully saved.
''' This would include unique key failures because of multiple attempts with the same file.</remarks>
Private Sub moveFile(name As String, good As Boolean)
Dim targetFileName As String
Dim fi As FileInfo = New FileInfo(name)
Try
If good Then
updateStatus("Moving file to Good")
targetFileName = Path.Combine(ProcessedFilesBaseFolder, "ProcessedFiles", "Good", fi.Name)
Else
updateStatus("Moving file to Bad")
targetFileName = Path.Combine(ProcessedFilesBaseFolder, "ProcessedFiles", "Bad", fi.Name)
End If
fi.CopyTo(targetFileName, True)
fi.Delete()
Catch ex As Exception
'It is possible duplicate processing attempts on the same file could be expected to be "normal"
LogErr(ex.Message, True, LogLevel.ERR)
End Try
End Sub
如果这两个目录不存在,则在程序启动时创建它们。以管理员身份运行...无济于事。目标是4.5.2。
为什么不引发异常?