There isn't a built in function for that. What you need to do at the start of your process is raise the filesystemwatcher.created event for each file in the folder.
This will make it "look like" all the pre-existing files were just dropped into the folder.
- foreach (string ThisFile in Directory.GetFiles(PhotoDirectoryPath,"*.jpg"))
-
{
-
string FilePath = Path.GetDirectoryName(ThisFile);
-
string NameOnly = Path.GetFileName(ThisFile);
-
FileSystemEventArgs FSEAe = new FileSystemEventArgs(WatcherChangeTypes.Created, FilePath, NameOnly);
-
fileSystemWatcher1_Created(this, FSEAe);
-
}
I'l warn you right now that trying to directly process from within your filesystemwater.created method can be risky. Depending on how much proccessing you are doing and how many files already exist in the directory you can quickly create a crash.
What happens if there are 5,000 files in the directory when you hit [Start]? You will create 5,000 instances of the .created method.
I suggest that you use the .created method only for adding the new files to a list to be processed, then process that list periodically. This works for me.