Click here to Skip to main content
15,353,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a watchfolder written in VB code and it works fine...but how can I detect the creation of a file with the same name?

For example:
1. file 1.txt is created -> code goes in action
2. file 2.txt is created -> code goes in action
3. file 1.txt is created (again) -> no reaction from code
4. file 4.txt is created -> code goes in action

Is there a way to 'reset' the watchfolder?

What I have tried:

checked for methods but can't find the solution...
Updated 9-May-22 6:26am
Richard MacCutchan 9-May-22 6:00am
Your code will need to keep a note of all the files so it can check if one already exists.
Rob Bals 9-May-22 6:43am

you're absolutely right! I'v added some extra logging and the folderwatcher IS firing! The error is in my code as a part of not having multiple actions when a file is created.

My bad!!!! Sorry but anyway your hint helped me!


1 solution

Simple solution would be to check if the file already exists,
If System.IO.File.Exists(file) Then
    'donot fire
End If

Hope it helps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900