Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I am trying to trace IP-Address who is deleting files from my share folders. I have write a code to get information when trying to do something in my share folder but, I can't get the IP from where the delete event's is occurred.

Here is my Code:

C#
private void Form1_Load(object sender, EventArgs e)
        {
            FileSystemWatcher fsw = new FileSystemWatcher();
            fsw.Path = @"E:\Mahbub IT\";
            fsw.EnableRaisingEvents = true;
            fsw.Filter = "*.*";
            fsw.IncludeSubdirectories = true;
            fsw.Created += new FileSystemEventHandler(file_handler_function);
            fsw.Changed += new FileSystemEventHandler(file_handler_function);
            fsw.Deleted += new FileSystemEventHandler(file_handler_function);
            fsw.Renamed += new RenamedEventHandler(file_rename_handler_function);
        }

private void file_handler_function(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Created)
            {
                MessageBox.Show("New file created : " + e.FullPath);
            }
            else if (e.ChangeType == WatcherChangeTypes.Deleted)
            {
                MessageBox.Show("File is deleted : " + e.FullPath);
                //MessageBox.Show(Request.UserHostAddress);
            }
            else if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                MessageBox.Show("File modified : " + e.FullPath);
            }
        }

This is working good but, I want to add IP-Address in MessageBox.Show(Client::IP).

Thank you advance.
Posted
Updated 18-May-14 19:01pm
v2

Hi,

You can try this : http://stackoverflow.com/questions/11660235/find-out-usernamewho-modified-file-in-c-sharp[^]

I did not try it let see what happen...

Or Else you can try a paid product which is very good at this kind of work : https://www.eldos.com/cbflt/index.php#product[^]

Thanks
Suvabrata
 
Share this answer
 
Instead of using a Shared Folder of the Windows Operating System, create your own service which takes care of the sharing: then you can monitor everything.
 
Share this answer
 
Stop reposting the same question over and over again and spamming the forums.
 
Share this answer
 
Comments
[no name] 17-May-14 11:17am    
I think this one was the original, not the repost. But chances are high that I'm wrong ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900