I have requirement that one process will trigger generation of multiple files (i.e. N number of file), There will be an application that will notify an external process the success (1) or failure (0) of the file generation process. If N number of files are generated on specific folders then that will be the success criterion. The destination folders and completion time are different for N files. In addition to the completion of the complete file generation process will take different time of completion on different days based on data volume, network congestion etc . So scheduling a job to get the file count in a specific time will not a feasible solution here. Could you please put your suggestion here to address the problem?
Asked
Active
Viewed 36 times
0
-
1Are you looking for the filesystemwatcher to notify you of new files being created? https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?view=netframework-4.7.1 – Ken Tucker Mar 30 '18 at 09:12
-
write window service & use `FileSystemWatcher` – ChiragMM Mar 30 '18 at 09:51
-
@Ken Tucker: I don't have any predetermined approach in my mind. I am going to use the best possible approach. – Nilanjan Saha Mar 30 '18 at 12:18
-
@ChiragMM : Thanks for your reply. You mean that service will run for 24 * 7 and within that the Filewatcher will check the existence of file and do the needful.. I will try to implement that. – Nilanjan Saha Mar 30 '18 at 12:24
1 Answers
0
You can try FileSystemWatcher
class as follows :
private void keepchecking()
{
FileSystemWatcher wt = new FileSystemWatcher();
wt.Path = path;
wt.NotifyFilter = NotifyFilters.LastWrite;
wt.Filter = "*.*";
wt.Changed += new FileSystemEventHandler(OnChanged);
wt.EnableRaisingEvents = true;
}
private void OnChanged(object source, FileSystemEventArgs e)
{
MessageBox.Show("New FIle Detected");
}

Software Dev
- 5,368
- 5
- 22
- 45
-
Thanks Zack for your reply. It is along the line of that suggested by @ChiragMM. I will try that.. – Nilanjan Saha Mar 30 '18 at 12:24
-
-
Implement this,it should meet ur requirements :) ..If you face any issue , make sure to comment back .If u find the answer useful,please don't forget to mark it as answer – Software Dev Mar 30 '18 at 12:28
-
Zack The process shall notify once all the files are being processed. The destination folders are not same. I can put the destination locations in config files for N number of files but writing N cases that I am wanting to avoid, need some brain storming here. The other part that I forgot to mention that it will be part of a workflow and there will be sequential execution steps. Let say the step 3 will check the execution status of generations of files, hence I need to halt step 3 until the file generation process would complete. Anyway your thanks for your reply. – Nilanjan Saha Mar 30 '18 at 13:36
-
ur case is a bit complicated for me to understand from a comment , but what i see from here is u can use my method , don't u think ? this is the best way to do it – Software Dev Mar 30 '18 at 13:39