0

I´m writing a C# Program which record all changes in a UNC Path. I use the File-System-Watcher in c# to record all changes in my file \D/X/Y(UNC path).

It works very good but now my question: how is it possible to record the Client which change/delete etc. the file ?

EDIT: The UNC Path will be seen in the whole network and I want to record which user change/delete etc a file in the UNC Path (Every one in the network can change the files). Each edit will be saved in real time in a .txt file. So that i can see : who:PC2 what:change file:X who:PC1 what:delet file:Y

Sam
  • 77
  • 5

2 Answers2

1

Use the following code to get the credentials of the user that is logged in

string currentUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

If you put this wherever the code is for the file change/deletion is, this should work.

Take a look at this

You basically need to create an auditing process for this, I'm not aware there is a built in way to find information such as who last changed a file.

Community
  • 1
  • 1
Cubsoft
  • 1,147
  • 1
  • 10
  • 32
  • This is assuming that the logged in user is the only person who can modify the file. – gunr2171 Feb 26 '13 at 14:31
  • But with this im only be able to record which user un my PC change a file in the unc path ? i updatet my question to be more specific. – Sam Feb 26 '13 at 14:32
0

I'm not sure what you mean by "who" is claiming or modifying a file. As far as I am aware, you can view properties of a file (if you have permissions to view the permissions), the current user (see Jacooobley's answer), and the process that is locking the file.

I don't believe you can see the user who has last effected the file.

gunr2171
  • 16,104
  • 25
  • 61
  • 88