E_Blue
E_Blue

Reputation: 1151

I need to automate a process to open files created by another application

I have a JAVA application on a server that creates log files. I have, in other server, an application (VB.NET) that process those logs to search some strings; if I manually select the file it works all OK.

Now I need that the second application automatically open every new log file on the remote server every one minute.

So I wonder if there's any way to know when a new log file is created or what are the new files created since last minute.

The files have the following format name server.log.*.log so the files with different format name must be ignored.

More info: There's a second JAVA application on the first sever that delete logs older than one day.

Upvotes: 0

Views: 51

Answers (1)

the_lotus
the_lotus

Reputation: 12748

You can use Directory.GetFiles every minutes to get the list of all the files in the folder. Compare it to the previous list (that you keep in memory) and process the new files.

An other option is to monitor the folder for any changes. This can be done using the System.IO.FileSystemWatcher class. By setting the Path and the proper NotifyFilter you can see which files were created with the Created event as soon (or almost) as they appear.

Upvotes: 1

Related Questions