FileSystemWatcher doesn't work on FTP file drop

42 views Asked by At

I have a service that monitors a directory using FileSystemWatcher. That portion is relatively simple:

Protected Overrides Sub OnStart(ByVal args() As String)
    WriteToLog("ZMES SAP Importer - STARTED")
    Dim inifile As String
    inifile = AppDomain.CurrentDomain.BaseDirectory & ("ZMESImporter.ini")

    Try


        'Create Watch on the SAP Folder where Hana drops new files
        ZMES_FileWatcher = New System.IO.FileSystemWatcher()
        'ZMES_FileWatcher.Path = "D:\MES\SAP_DATA"
        ZMES_FileWatcher.Path = Path
        WriteToLog("Reading CSV file from folder: " & ZMES_FileWatcher.Path)
        WriteToLog("Proficy Connection: " & DB)
        ZMES_FileWatcher.Filter = "*.csv"
        ZMES_FileWatcher.NotifyFilter = (NotifyFilters.LastWrite Or NotifyFilters.LastAccess Or NotifyFilters.FileName Or NotifyFilters.DirectoryName Or NotifyFilters.Attributes)
        ZMES_FileWatcher.EnableRaisingEvents = True

        AddHandler ZMES_FileWatcher.Changed, AddressOf OnNewFile
        AddHandler ZMES_FileWatcher.Created, AddressOf OnNewFile

        ZMES_FileWatcher.EnableRaisingEvents = True

    Catch ex As Exception
        WriteToLog("Service OnStart Error: " & vbTab & ex.Message)
    End Try

End Sub

In my OnNewFile subroutine I am writing to a log file as soon as anything happens. When I drop a file manually, I can see from my logfile that it is working. When one is pushed via FTP - it does not get to the OnNewFile subroutine.

I made sure to use Changed and Created just in case. Also, FYI, this exact service works fine on a Windows 2008 R2 server, but the new server is Windows 2012 and it does not work. The FTP process is being delivered in the same manner as far as I am aware.

0

There are 0 answers