The best way to keep track of files being moved (possibly between disks), VB.NET (or C #)

I am developing a "dynamic shortcutting" application that creates special shortcuts that point to a registry entry and not to the actual file / executable. The registry entry contains the path to the required file. I want to run a daemon that monitors related files and updates their registry entries if they are moved or renamed. Renamed I can work with System.IO.FileSystemWatcher, but what is the best way to handle moved files?

I know that this goes beyond the basic functions of FSW (despite the fact that this is working with a low-level file system). The question is, what is the best way to do this?

  • Most of the posts / articles I read suggest ways that feel completely “hacked,” which are mainly related to finding a deletion, followed by creating a file in a new location, and connecting two-sized files, meta data, the time between delete / create triggers, hashes, etc. This may be the method I have to resort to, setting up FSW on all drives. However, I hope that there may be a better way.

  • Is it possible:

    2.1. Listen in the shell and "hear" the move operations?

    2.2 Or (even more radically) replace or add something to the shell move operation, which either triggers an event, or itself performs the task of updating the registry, eliminating the need for the daemon?

, , 1. , . ( VB.NET , #, ).

+4
4

[ , "" ]

( ) ( ):

  • , (.NET) - FileSystemWatcher, "" ( , ). FSW , , (.. ) . "" - - , , , ( ), . , , , , , , .

  • ( ++) API, , "". , , , "" "" .

  • ( ++ , , ), : , , .

, , FileSystemWatcher (, , ), . [no code atm, , , ].

FileSystemWatcher ( , ):

0,1. FileSystemWatchers.

FSW , (, ).

0,2. .

.

0,3. .

; .

3.0.1. , / / .

, , ( ). , , . "" , , ( , , , .)

3.0.1.1. ize/attributes/take hash?

, +. , ( - , ) , "", , . ( ) , , , FileSystemWatchers; "" , , .. : , , , ? , , , , , , ""? , , ( .) , FileSystemWatcher . , ( ), , . (, / / , ), .

3,1. 1. .

"" "" . , "" , ( , ), "" (, ), , , , 1000 , , .

3.2.0. .

, , , , , . , docs :

, FileSystemWatcher , , .

(.. /, / ). , , , .

3.2.1. 2. .

, , , , FileSystemWatchers , ( "/" ".". ) , , , , et voila!, , . , , , "".

3.2.2. 3. .

: , , . "", "". 3.1 3.2.1: "delete", , - . , "listen" ( ) "" , , , . , . , , , , , / "" "" , , , .

3.3. : .

, , , ( ); ( , , ) .

3.3.1. 1: "" , .

, "" . , , "" , . , .

3.3.2. 2: "", .

, , . "" , , . , - , "" .

3.3.3. 3: (UNTESTED), , "" "" *.

, , . [ - , ( ) ]

3.4. quandry: ?

, , , , File.txt. , , File.txt. , , , ( ) . , , , "" ? (, , ​​ -)?

+2

api, # - , . FileSystemWatcher.. " " - "".

/ , MoveItem MoveItems IFileOperation, MoveFile - Kernel32.dll... , , .

0

, : (a) /, , . / ; () .

, , . , . , (: ), , , , .

0

Bump update: StackOverflow, , ( SO), MicroSoft UserVoice, MOVE FileSystemWatcher. , , MicroSoft . , , .

0

Source: https://habr.com/ru/post/1532077/


All Articles