You can reference the FsObserver.exe file as an assembly, as though it were a DLL. All of the properties have been exposed, so that you can set up an FsObserver instance and then invoke StartWatcher() within your own app.

Here is the help documentation from the command line:

FsObserver.exe  [-p[ath] {path}]  [-f[ilter] {filter}]  [-s[ubdir] {subdir}]  [-e[vent] "{LastAccess, DirectoryName, etc}"]  
[-a[ction] {action {actionParam}  }] [-d[elay] {ms}]  [-cp/-comparepath {path}]  [-v[erbose]]

The FsObserver command monitors file system events and performs an action given your execution parameters 
such as logging or mirroring.

 -? or -help    Shows this text.

 -p or -path    Specify the path to watch, i.e. "C:\". Use "". The default watch path is current directory.

 -f or -filter  Specify the file filter, i.e. "*.txt". The default filter is *.* (all files).

 -s or -subdir  Specify to extend watch to subdirectories of path.

 -e or -event   Specify events to watch for: FileName, Attributes, LastAccess, LastWrite, Security, Size, 
               CreationTime, DirectoryName. Use "".

 -d or -delay   Specify the number of milliseconds to delay the event handler. The default delay is 5000 ms.

 -cp or -comparepath

                Specify to set the compare path property. This is only used with "-action copyvscompare". If the 
                observed file also exists in the compare path, no action will occur.

 -v or -verbose Specify to describe the event and how it is handled in greater detail.

 -a or -action  Specify the action to invoke when a file is touched (modified, added, or deleted).

                Action Options:

                -action echo

                        Displays the touched file(s) in the console.

                -action command "{command} %1"

                        Executes a command, optionally using "%1" as the observed file path, %2 as the observed 
                        event types (the -e flag), %3 as the filename, %4 as the verbose filename descriptor, and 
                        %5 as the verbose file path descriptor.
                        Use quotation marks ("") around the whole -action parameter.

                -action copy "{target directory}"

                        Copies the touched file(s) to the specified target directory, respecting the virtual directory 
                        hierarchy. Surround this parameter with quotation marks ("").

                -action copyvscompare "{target directory}"

                        Copies the touched file(s) to the specified target directory, respecting the virtual directory 
                        hierarchy. The file copy is not performed if the file(s) exist in the path specified by the -cp 
                        flag.

Example:

 FsObserver.exe -p "D:\dev\prj\cmd\FsObserver\FsObserver\bin\Debug" -f "*.txt" -s -e "FileName, LastWrite" -a "echo" -d 1000

This example will monitor the current directory and its subdirectories for renames and edits to .txt files and 
will echo the change after a delay of 1000 milliseconds.

Last edited Jun 8, 2010 at 12:39 PM by stimpy77, version 6

Comments

No comments yet.