Click here to Skip to main content
15,914,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I would like to have an application which will track the list of files copied from and to an USB drive.

How can i do that using C#.net?
Can anyone help me plz?

Regards,
San
Posted

You don't. Not easily anyway.

Windows makes no distinction between an application opening a file for Read access and a copy operation. The two operations are identical.

This would require low-level Windows knowledge and the know-how for writing drivers and kernel-level debugging. You'd track which processes/threads have which file handles open for any kind of Read access and if those same processes/threads have file handles open for Write access. Then you can reasonable suspect that a copy operation is going on.

Good Luck!
 
Share this answer
 
Comments
Sanju Sanju 20-Sep-12 2:36am    
Thanks Dave.

Can you show me a sample how to do kernel level debugging using C#.
Dave Kreskowiak 20-Sep-12 7:36am    
You say that like there's a 10 minute tutorial you go through and you'll know everything there is to know. Sorry, but this takes YEARS to get good at.

You can start by reading the article series found here on CP:
http://www.codeproject.com/search.aspx?q=Debug+Tutorial+Part+&doctypeid=1&authorid=961412
You can use the class System.IO.FileSystemWatcher: http://msdn.microsoft.com/en-us/library/x7t1d0ky.aspx[^].

Good luck,
—SA
 
Share this answer
 
Comments
Sanju Sanju 20-Sep-12 2:35am    
Thank you Sergey..

System.IO.FileSystemWatcher is watching only when new file is created or existing file is modified.

My Requirement is i need to know the file is pasted here from which location and copied to which location.

Can you help on this?
Sergey Alexandrovich Kryukov 20-Sep-12 11:34am    
No, it will watch the creation of the file. Copy/Paste of the file is implemented as creation a copy of the file.
--SA
Dave Kreskowiak 20-Sep-12 7:35am    
FileSystemWatcher was not designed to watch an entire drive. Performance and accuracy degrades as you get into larger and larger directory trees.
Sergey Alexandrovich Kryukov 20-Sep-12 11:33am    
True.
--SA

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