Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. process modifying/openning file

process modifying/openning file

Scheduled Pinned Locked Moved C#
csharpjsonhelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lost_in_code
    wrote on last edited by
    #1

    hi,can someone help me with this.... i want to know how to get the file name currently being modified/openned by certain process, i know about FileSystemWatcher tool but i want to get it in another way(i mean what process x is openning or modifying at a specific moment). is there any API or c# code to it??? any help is appreciated

    D 1 Reply Last reply
    0
    • L lost_in_code

      hi,can someone help me with this.... i want to know how to get the file name currently being modified/openned by certain process, i know about FileSystemWatcher tool but i want to get it in another way(i mean what process x is openning or modifying at a specific moment). is there any API or c# code to it??? any help is appreciated

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      lost_in_code wrote:

      i want to know how to get the file name currently being modified/openned by certain proc

      Unless the process exposes some kind of ommunication mechanism, there's no way to tell.

      lost_in_code wrote:

      i know about FileSystemWatcher tool

      The FSW won't work for you anyway since it can't tell that a file was opened at all. All it can see is the changes in the files timestamp attributes, which don't change if you open a file for read access.

      lost_in_code wrote:

      i want to get it in another way(i mean what process x is openning or modifying at a specific moment).

      The only way I can think of would be to enumerate all the process handles, and all of the file handles in the system and start trying to match them up with each other. But, there is no way to tell an .EXE file from a .DLL file from a .TXT file from a .DOC file, or any other file type. On top of that, most apps out there don't hold files open when they load them, so there's no file handle to try and match up anyway. The bottom line is what you want to do is extremely difficult and unreliable.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups