views:

57

answers:

3

I want to make a winform application that tells you whenever you open it all the changes that have been made since last opening, and maybe record a log of it, such as:

  • File/folder creations
  • File/folder renamings
  • File/folder exclusions

I've figured i have to do four tasks:

  • Save the folder state (tree) in a reloadable format
  • Load this information back
  • Compare this information with current state gathered as needed
  • List changes, log and display them

I've come up with some ideas, what have you got to help me ?

(I'm vs 08 and .NET 3.5)

---[EDIT]---
Renaming should be impossible, it could just be an exclusion and a creation, since folders don't have unique ID's in Windows.

---[EDIT]---
The real purpose of it is learning, and if it works, i may as well use it and handle over the source code or something, I'm sorry for not mentioning this before, I'm not interested in ready solutions.
I want to watch a network shared folder, in which I already have an application currently in use (that i've made) that has a FileSystemWathcer to pop up a message balloon in the tray everytime something happens in any file or any folder/subfolder.
What i want is being able to compare the prior and current state in a separate application (initially) and if successfull, implement it in the currently running application. But that is quite irrelevant for the question.

A: 

That's a good way to go.

Another idea is to use the NTFS change journal, as described in MSJ September 99 and MSJ October 99. The first run of the app has to enable the journal for the needed volume and it's done. The subsequent runs read the journal and extract the change info for the directory of interest.

Note that this is harder than it sounds as the API is quite low-level. And there is the - very small - risk that someone turns off the journal between runs.

Timores
+1  A: 

My suggestion is to serialized the state into an XML file. Utilize XML Diff to create the diffgram and extract the information out from the diffgram produced for display. If you have the correct nested structure, diffgram will do the element matches and it will save you plenty of time from writing your own comparison of folder-folder and recursive sub folder comparison as well. All you need is to work out how to then digest the diffgram produced which is usually quite straight forward. Each element is usually marked with attribute to say that it is changed, added or deleted.

Fadrian Sudaman
A: 

Such an application already exists. It's called Subversion and there also exists a very good client for Windows called TortoiseSVN.

If you need to know what features your program needs or don't know how the UI should be designed, take a look into their documentations (subversion doc, tortoise doc) or even the source code.

Update

So if you just want to do this on your own for training purposes you should also take a look into the docs or the source code to get an idea on how they accomplished this task (eg. creating a hidden subfolder where the old state is saved) to get an idea how you can solve this problem for yourself.

Oliver
Wouldn't be an overkill? From the question it sounded that the application is only interested with the metadata info like date of change and what changes are made. If you are putting a VCS on an entire file system on a PC, this is just not effective. Then you have the check-in check-out operations for each change. The diff gram being stored for all the content changes are also irrelevant to the user (based on my understanding on the question)
Fadrian Sudaman
Yes, from the current *known* requirements it could be an overkill. But maybe these are just a starting point and the holy grail for all the problems is just to use an repository. But this is a decision the OP has to made. Also he didn't wrote anything that he wants to watch the entire file system on a pc. This is an assumption you just made.
Oliver
Check out the new EDIT.
MarceloRamires