0

How can I monitor the file activity of a COM object in my C# application? I want to provide the user with a status bar or other activity indicator while the COM object is "uploading" a file. I was hoping that I could read the current position in the file from another thread.

longneck
  • 11,938
  • 2
  • 36
  • 44
  • Does this COM object not have any events? – noseratio May 09 '14 at 23:35
  • You need the handle to the file so you can find the position. Odds that you'll manage to reliably dig this out of a COM component that you don't have source code for are minus one percent. Get in touch with the programmer for this component and ask for an event. – Hans Passant May 09 '14 at 23:47
  • Is this a COM object you made and you can change the source for? If not then you are confined to using the information that the object presents on its interfaces. – M.M May 10 '14 at 00:30
  • I was hoping that I could use something like system.diagnostics to get a list of all open file handles in my process. And no, I don't have the source, and asking the vendor to modify the library is not an option. – longneck May 10 '14 at 00:37
  • Or Process.GetCurrentProcess() – longneck May 10 '14 at 01:10
  • 1
    Good luck. See the [answer to this question](http://stackoverflow.com/questions/177146/how-do-i-get-the-list-of-open-file-handles-by-process-in-c) - you'll need to get the list of all file handles in the system, and then filter that to your process, then filter some more based on your existing knowledge of your application. There's nothing in the file handle to say "I was opened by DLL X". – Eric Brown May 10 '14 at 17:54

0 Answers0