How to use file watcher in WebAPI?
*I want check folder empty or not
*Not empty means the excel sheet in folder to inserted into database
How to use file watcher in WebAPI?
*I want check folder empty or not
*Not empty means the excel sheet in folder to inserted into database
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pasang TamangPosted Jan 11, 2023, 11:07 AM
Hi Sujay,
Personally I won't recommend to use Filewatcher in WebAPI project. When there is no active request on WebAPI then app pool will go to idle and in that case Filewatcher will not work. What you can do is either create a console application and run it through windows scheduler or you can create separate windows service. For me I solved the problem by using web scheduler HangFire. Every 5 minutes Hangfire check my folder if there is file or not. You can read detail about HangFire integration here https://code-maze.com/hangfire-with-asp-net-core/
Regards,
Pasang
Amit MohantyPosted Jan 11, 2023, 10:29 AM
If you want to check folder is empty or not, you can use this.
If you want to do this using FileSystemWatcher