0

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.

6
  • learn.microsoft.com/en-us/sysinternals/downloads/procmon Commented Dec 13, 2023 at 8:50
  • @HansPassant I have no idea how Process Monitor helps me with this. I've used that many times before, but in this instance it doesn't seem like it could be helpful at all. Commented Dec 13, 2023 at 12:20
  • When you post the trace you see, there will be somebody here that can tell you how to modify your code. I could guess at it, but why would I when you can provide the trace. Commented Dec 13, 2023 at 12:22
  • I've not used trace with ProcMon. How would I do that and how does that benefit? Sorry - just not aware of this usage of ProcMon and how it would be able to show the FTP file drop and then the FileWatcher not seeing the drop. Commented Dec 13, 2023 at 12:26
  • You haven't used it before. Commented Dec 13, 2023 at 13:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.