File Watcher +Win Service

  • Thread starter Thread starter Marcelo López
  • Start date Start date
M

Marcelo López

Hi all.
I'm developing a Windows Explorer like app.

I have my own repository to store the files and a bd where i keep the path
to each file.

I have to watch the repository all time to avoid modifications by other
people. So that, i'm using a win service in wich i implement a file watcher.

I have two basic questions:

1) I'm implementig methods to restore the information in the bd if someome
delete, rename or move a file in my repository. The problem i have is that
the file watcher
throws more than one event for example if someone moves a file. So, how can
i know which other events are waiting in the queue (and eventually how can i
acces and navigate to this queue) or is there another way to restore the
changes made to any file on my repository ??

2) My app also can modify the files in the repository, so, i don't want in
these case the file watcher perform the restore actions !! how can i differ
the changes made by my app or somebody else ?? is there any way to ask if my
app is running or something like that ??

Any suggestions are welcome !!

regards !!

Marcelo López
Inforcorp. Uruguay. Latin America.
 
Hello i guest that a better protection for your files it's to put the folder
protected with access only to a user that you control, start your app with
that user account, and you will be the only one with the permision to chage
the files because only that user can access that folder and chage the files.
 
OK, it seems to be an interesting solution.
So that, i'd like to get more information, because i never have worked with
permissions and users in C#.
What happens if someones access the directory using for example the Win
Explorer ?? Could the administrator give himself the same permissions that
my application and delete or move the files protected ??

My requirement is to " avoid modifications on my files by somebody else "
when my app is running or not.
If the solution you are giving to me satisfy it, it is more than welcome !!!
If the answer is YES, i'd like to get more information about creating an app
user and managing its permissions on my app start, etc.

Regards !!!

Marcelo
 
Using windows explorer they would get an error trying to write to the
directory. However, an administrator will always be able to bypass this.
(note that an admin could also stop your service and mess with the files as
well). However, an admin would have to explicitly take control of the
directory, so it wouldn't be an accident.

So, you can't keep an admin from doing it no matter what. But you can make
it hard:
Create the directory and make it owned by your app user
Give your app user full control, remove everyone else
Make sure that the permissions from parents are not inherited

No only that user can access the directory.
 
OK, it sounds good.

Where can i get a tutorial or similar to learn about creating users
programatically, asigning permissons, etc with C# ?

I have to do it when the user installs my app.

I'll be pleased for that.
 
Back
Top