-1

I have inherited application that, among many other things, has to watch if user writes/deletes text file into specific folder.

Currently, the application uses timer and polls after 5 seconds. I find this ineffective, and wish to improve this part of code.

My question is about existence of the .NET function that monitors changes in directory. Is there such function I can use to detect when a file is written/deleted in a specified folder?

Thank you.

1

2 Answers 2

2

Yes, you have the FileSystemWatcher class. It does exactly what you're looking for

Sign up to request clarification or add additional context in comments.

Comments

0

Yes there is. I would suggest you take a look at the FileSystemWatcher class:

http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx

It's quite easy to set up, and it monitors for Win32 events, so is relatively inexpensive to use.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.