There is a folder on the desktop. There is an empty txt file in this folder. According to my algorithm, when the software has found "something", it records this "something" in this software. A software that works in the background monitors the change of this mht, in which "something" should be written. As soon as this empty question from the first line of the question is changed, the software that keeps track of the change creates 5 say empty ones and when I created it, and turned off myself ... I sort of understood it. The question is how to create this software that follows ...
- Look in the direction of version control systems - Git, SVN, for example. If using them is not an option, then try to make something like it - create a copy of the first file and with a timer check the working file and its copy with the background software. - Anatol
- If both of these software are yours, then it is better that they communicate not through writing / reading a file, but in a more direct way. For example, through a named pipe (named pipe). - Alexander Petrov
|
1 answer
You have a rather common question, so the answer will also be general:
To track files use
FileSystemWatcher.private void StartWatchingFile() { var watcher = new FileSystemWatcher(); watcher.Filter = "some_file.txt"; watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Changed += OnFileChanged; } private void OnFileChanged(object source, FileSystemEventArgs e) { // ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ ΡΠ°ΠΉΠ»Π° ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»ΠΎΡΡ, Π²Π°ΡΠΈ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ, Π·Π°ΡΠ΅ΠΌ Π²ΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ Environment.Exit(0); }Such "tracking" applications are more conveniently arranged in the form of Windows services (in this case, it is better to complete your work by calling the
Stop()method).
- @anreycha and what should be added to the user system? - komra23 pm
- one@ komra23 press Ctrl +. and Studio will tell you. Or look in MSDN. - andreycha
|