How to monitor files create by a specific process

  • Thread starter Thread starter john.johnhart
  • Start date Start date
J

john.johnhart

I have a program that will be launching another process. I want to be
able to monitor the files created and/or modified by this second
process. I know about FileSystemWatcher, but there's no way to limit
it to a specific process that I know of. Any ideas?
 
Can't you just monitor the folder where this other Process creates/modifies
files? If you have the code for the second process, you could add an event
which you could subscribe to from the first process, then raise it from the
second process when you create or modify a file.

I don't know if this helps without more info, but if there are any flags
output by the Process to the standard output stream when it creates or
modifies something, you could use the following code to redirect and capture
it.

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "test.exe";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

Regards,

Peter
 
I wish it was that simple. The process can create files in any
directory, so I watch from the root directory on down. I need to know
that this process created the new file and it wasn't some other process
already running on the system. Modifying the second process's code is
also not an option.

Thanks for the suggestion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top