0

I am currently developping an application where I need to check if the user has replaced a file (by MD5) and I thought of a Timer.

A Timer that checks every 1-2 seconds If the MD5 of the file is not what I expected, If not, I need to disable a MenuStripItem.

My question is, is it bad to edit a control's property every 1-2 seconds?

Taie
  • 1,021
  • 16
  • 29
Haytam
  • 4,643
  • 2
  • 20
  • 43
  • I think what you need is a [FileSystemWatcher](https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx) – Josh Part Sep 04 '16 at 17:54

1 Answers1

1

Modifying a control's property every 1-2 seconds does not seem like a bad idea, but checking a file's hash so often seems like a bad idea. You should at least compare the file dates and size before comparing the hash.
A better approach would be to check it only when the menu item is used.
FileSystemWatcher is the usual way to keep track of changes in a folder, but it is not fully reliable FileSystemWatcher vs polling to watch for file changes

Community
  • 1
  • 1
Slai
  • 22,144
  • 5
  • 45
  • 53