Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.78/5 (3 votes)
See more:
I want to know a process what file create or delete or change in Windows? Is it possible in c#? Please suggest me how I should do it? Give me example or useful link. Thanks

What I have tried:

I see the ProcessExplorer but I don't know how it work.
Posted
Updated 17-May-16 9:42am
Comments
BillWoodruff 17-May-16 13:46pm    
Do NOT post the same question in two forums.

Getting basic process information is possible from C#, see example here:
Process.GetCurrentProcess Method (System.Diagnostics)[^]

If you want more, you will need C / C++, see example here:
Process viewer[^]

Another option would be to use Sysmon by SysInternals, this is a free tool that logs to the Windows Eventlog. Your program could monitor the Eventlog which is possible from C#. Download Sysmon here: Sysmon[^]

Old Sysinternals source code (before it was acquired by Microsoft) can be found here: GitHub - xcud/sysinternals-source[^]
 
Share this answer
 
v3
Comments
saeedmir 17-May-16 13:48pm    
Thanks @RickZeelan. means its impossible in c#? Process viewer is good but I like write with c#? Is there any way?
RickZeeland 17-May-16 13:53pm    
Can't say that it's impossible in C#, but I think this stuff is way too low level for C#.
I will have a look into the subject and let you know if I find anything interesting !
saeedmir 17-May-16 14:02pm    
Thanks man. I think it sovle with find "process handle" but yet not found useful content...
Please see this class: https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx[^].

[EDIT]

The comment by RickZeeland below is important; please see:
FileSystemWatcher Follies | Windows SDK Support Team Blog[^].

Sorry that I did not mention the problem with this class.

—SA
 
Share this answer
 
v2
Comments
RickZeeland 18-May-16 10:05am    
But beware of it's limitations, read about it here: https://blogs.msdn.microsoft.com/winsdk/2015/05/19/filesystemwatcher-follies/
Sergey Alexandrovich Kryukov 18-May-16 10:37am    
Thank you about this important comment. I knew about the problems with this class but failed to mention it.
Good link. I credited your comment in the edited version of my answer.
—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