I am running a FileWatcher in a folder that is looking for a files with extension .stl and .txt
watcher.Filter = "*.stl";
watcher.Filter = "*.txt";
These files are added to the FileWatcher folder at the same time, and once they are added, I have a process set to run.
Once this process exits, I need to have both files (.stl and .txt) deleted from the folder they were added to.
How can I go about doing this?
I can get the path of the added files through fullPath = e.FullPath;
Once my process completes and exits I have it check if the File extension exists, and if so, deletes it.
process.Exited += new EventHandler(myProcess_Exited);
process.WaitForExit();
private static void myProcess_Exited(object sender, System.EventArgs e)
{
if (File.Exists(@fullPath))
{
File.Delete(@fullPath);
}
}
My code is able to successfully complete, but it is only deleting the .txt file, and I need it to delete the .stl as well.