Could someone please tell me where I am going wrong with this code please, it does’nt go into the “logchange” sub:
Imports System
Imports System.IO
Imports System.IO.File
Imports System.Diagnostics
Imports System.Data
Imports System.Data.OleDb
Public Class MainForm
Public watchfolder As FileSystemWatcher
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtPath.Text = “H:\Test\Parent\Arrive”
End Sub
Public Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Created Then
Dim MyConnection As OleDbConnection
If Path.GetExtension(e.FullPath).ToUpper = “.XLS” Then
Try
”my processing code here
Catch ex As Exception
MyConnection.Close()
End Try
End If
End If
End Sub
Public Function FolderExists(ByVal FolderPath As String) As Boolean
Dim f As New IO.DirectoryInfo(FolderPath)
Return f.Exists
End Function
Public Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
watchfolder = New System.IO.FileSystemWatcher()
‘This is the path we want to monitor
If FolderExists(txtPath.Text) = True Then
watchfolder.Path = txtPath.Text
‘event handlers
AddHandler watchfolder.Created, AddressOf logchange
watchfolder.EnableRaisingEvents = True
Else
MessageBox.Show(“Invalid Path, Please try another”, “Incorrect Path”, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End Class
I had this working about two days ago but the file was deleted on me and I can’t get it working now to save my life.
Thanks in advance colonel-yum-yum