FileChangeTrigger - Get the name of the file which caused the trigger

im using the FileChangeTrigger, i need to get the created time and exact file name which caused the trigger to be fired.

I have tried “NotifyFilters.FileName.ToString” however this just returns “FILENAME”

Is there a way to get the exact file name example ; XYZ.csv in the event handler using monitor events?

kind Regards

harri

@badita

Hi @Haripriya,

In my example it basically gets the information from the file that was recently created. However, let’s wait for @badita’s answer or someone else, because in my example it will only work for files that were recently created, however it wouldn’t work if the user changes/deletes the previous files or something like this, it won’t get the information you need. I tried to get this information from NotifyFilters as well, but it was not possible :frowning:

Main.xaml (9.5 KB)

You may also try to change the order by using other properties and maybe it will achieve what you want:

4 Likes

Hi,

Thanks for your response, but the solution is risky, i hope @badita could help us a little more with a proper solution to only get what was actually triggered.

1 Like

I’d be interested to find out how to do this as well. I can’t seem to get any information back from GetEventInfo after a FileChangeTrigger event. I have downloaded @acaciomelo example and this appears to be safe. Would you recommend using this approach?

1 Like

@acaciomelo I try to copy two files into monitor folder at the same time, but it sames doesn’t work by your example. It pop up the same info twice time. Do you have any good idea about this condition?

Hello,
Can we use file system trigger in unattended mode - basically for bot running in the background

Yes, you can use this trigger in an unattended robot.

You can get the name of the file which caused the trigger by using
Get Event Info Activity and settings its property TypeArgument to System.IO.File.SystemEventArgs.
Your return variable should have a FullPath method which gives the name of the file which caused the trigger.
Main.xaml (6.9 KB)

2 Likes

@Yoshi_Akiyama’s xaml solution works fine however when doing it with the UiPath.Core.Activities.FileChangeTriggerV2, it doesn’t seem to trigger the Event Handler.

Anyone have any idea’s why? or any other solution for getting the name of the file that changed?

Main.xaml (6.7 KB)

Thanks @Yoshi_Akiyama works like a charm. But I just can use the v1 and not the v2. Somehow the v1 is not in my list. You have an idea how to use the v1 without copy pasting it from your example?

Hi @kwoxer
I’m looking into this right now. Mean time please downgrade UiPath.Sytem.Activities to 19.8.0
to have File Change Trigger V1 to show up in the activities panel.
If your not familiar with Package manager please refer to below doc.

Ohh good to know. Thanks. But simply adding v1 to latest version would be best :wink:

I find how you can retrieve the file information using v2. Just access the FileChangeInfo variable. you dont have it on your list but it will exist on the FileChangeTriggerV2 context.
it has the same properties that FileSystemEventsArgs has. Hope this helps.
Cheers
image

Hello everyone, it seems like the documentation team is taking some time to create the documentation, so going to provide a quick update here.
Basically, V1 had issues, thus we created V2.
V2 has a scope inside, so instead of putting File Change Trigger inside Monitor events activity, please use it stand alone.
I am pushing the documentation team to update.

Documentation has been updated.
https://docs.uipath.com/activities/docs/file-change-trigger-v-2

In V3 simply use the args:

args.FileChangeInfo.FullPath
args.FileChangeInfo.Name
1 Like

I integrated the code into my project, it worked, thank you,
got my job done

1 Like