DatabaseDude
Programmer
I have an Access 2007 application that "watches" a folder to determine if new files or added, or if existing files are renamed. This uses the .NET FileSystemWatcher class, incorporated into a DLL wrapper named IOLib.
I've downloaded all the code and made it work without error in a VB6 form: (scroll down to "Using the FileSystemWatcher from Visual Basic 6").
However, in Access 2007, the application crashes frequently upon any of the events firing. Lately it seems to have been much more stable on my Win XP Pro box, but it absolutely refuses to run on Vista Business.
Here's the form code (with the exception of the AttachPDF subroutine, which never gets called due to crashing):
Any pointers? Thinking it's something with the WithEvents, but gone as far as I can at the moment.
Thanks much in advance!
I've downloaded all the code and made it work without error in a VB6 form: (scroll down to "Using the FileSystemWatcher from Visual Basic 6").
However, in Access 2007, the application crashes frequently upon any of the events firing. Lately it seems to have been much more stable on my Win XP Pro box, but it absolutely refuses to run on Vista Business.
Here's the form code (with the exception of the AttachPDF subroutine, which never gets called due to crashing):
Code:
Option Explicit
Option Compare Database
Private WithEvents fsw As IOLib.FileSystemWatcherWrapper
Private Sub Form_Load()
Set fsw = New IOLib.FileSystemWatcherWrapper
With fsw
.InitWatcher "c:\foldername"
.IncludeSubDirectories = False
.EnableRaisingEvents = True
End With
End Sub
Private Sub fsw_Created(ByVal e As IOLib.FileSystemEventArgsWrapper)
Dim strFileName As String
strFileName = e.Name
If Right(strFileName, 3) = "pdf" Then
Call AttachPDF(e.Name, e.FullPath)
End If
End Sub
Private Sub fsw_Changed(ByVal e As IOLib.FileSystemEventArgsWrapper)
' Do nothing
End Sub
Private Sub fsw_Deleted(ByVal e As IOLib.FileSystemEventArgsWrapper)
' Do nothing
End Sub
Private Sub fsw_Renamed(ByVal e As IOLib.FileSystemEventArgsWrapper)
Dim strFileName As String
strFileName = e.Name
If Right(strFileName, 3) = "pdf" Then
Call AttachPDF(e.Name, e.FullPath)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set fsw = Nothing
End Sub
Any pointers? Thinking it's something with the WithEvents, but gone as far as I can at the moment.
Thanks much in advance!