Directory Monitoring System using UiPath

Hi,
is it possible to create a full directory monitoring system which keeps track of newly added files, deleted files and modified files. It must keep updating a .CSV file after every modification in directory. I tried it using “File Change Trigger”, but keeping track of files after every modification in a .CSV seems quite complex. Any suggestions. Also, i need those files for some further use.

This one may help you. Please check it out.

Regards,
Karthik Byggari

1 Like

So as i understood, we need to provide custom implementation in C#.

Look into this -

1 Like

Looked in to it. But can’t find any documentation regarding its usage.

Hi,

Please Refer the below link

Monitors changes on a specified file or folder

1 Like

Hi. In my workflow i have used “File Change Trigger” activity which writes to a .CSV file every time a change is made in a directory. But sometimes it repeats the result. I wanted to upload workflow but being a new user i can’t.

May be you missed these options to set.

  • NotifyFilters - A bitwise combination of filters that are to be watched for changes.
  • ChangeType - The type of changes to be watched for.

Please check for the possible Notifiers and change types.

Regards,
Karthik Byggari

Hey @KarthikByggari, do you know if this can be used in Production?

Hi @SenzoD

You can use it on any file on windows file explorer. Doesn’t matter the environment.

Regards,
Karthik Byggari

1 Like

Hey @raviranjan, i know this post is very old, but i thought it would help someone if they also cannot find the documentation for this specific activity. Under resources there’s .pdf user guide that you can download and follow.

@KarthikByggari, Thanks bro.

1 Like

@SenzoD , How does file change trigger with option “Include subdirectory” set to True work ? does it monitor for all subdirectory from the given path ?

Hi everyone,

Bringing a different perspective to this discussion, realting to a slightly different requirement. Looking at the original post, it seems to me that @raviranjan was just after a bot that monitored a folder (and subfolders) on a continuous basis and reported any changes made. I had the same requirement, followed by a couple of things to do on the newly discovered files,
e.g. add a queue item for another bot to pick it up.

I have tried the approach with FileSystemWatcher and also UiPath Team’s File Watcher. They are excellent for tracking changes on each event, but difficult to implement or use when multiple files get dropped into a folder.
Or, while the bot is doing other activities in a sequence, what if a new file gets added in between? It mostly doesn’t get tracked because the bot isn’t actively listening for changes.

I found this simple approach works in my situation. Create two String[] objects as follows:
Assign
listFilesBefore = Directory.GetFiles(strMonitoredFolder, "*.*", SearchOption.AllDirectories)
(wait for T seconds, where T = given interval)
Assign
listFilesBefore = Directory.GetFiles(strMonitoredFolder, "*.*", SearchOption.AllDirectories)

Create an IEnumerable object:
Assign
listFilesNewlyAdded = listFilesAfter.Except(listFilesBefore) (explained here)
This gives you the Set Difference between the two lists. You can then loop through the list and use the filenames as you need to.
At the end, Assign
listFilesBefore = listFilesAfter
This way your latest snapshot of files gets assigned to the before object and only new changes are considered.

Program is attached here: Folder Monitor.xaml (10.2 KB)

Disclaimer: This worfklow only tracks newly added files, not the ones that were removed. This is because the .except works only one way. If you would like to track changes both ways, you may need to tweak the program a bit to achieve this.
Also, it will not work for overwritten files with the same name, it should work on renamed files though. It’s just a string comparison of filenames as they were before and after each scan. Please take this into consideration when using the code.