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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to know a file is accessed by another process

how to know a file is accessed by another process

Scheduled Pinned Locked Moved C#
helpquestionjsontutorial
2 Posts 2 Posters 2 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.
  • N Offline
    N Offline
    NotProfessional
    wrote on last edited by
    #1

    My program is watching for a directory on any incoming file and then move it to other places. Another application produce the data file to that directory. The problem is: my program always get the error message: access violation So, how can I know from program point of view that the file is accessed by another process? Is there any related API? Thanks in advance.

    H 1 Reply Last reply
    0
    • N NotProfessional

      My program is watching for a directory on any incoming file and then move it to other places. Another application produce the data file to that directory. The problem is: my program always get the error message: access violation So, how can I know from program point of view that the file is accessed by another process? Is there any related API? Thanks in advance.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      For files opened over a share, you can use NetFileEnum. For the local system, there is a function or two in the Win32 API but they are undocumented and unreferenced. There is a program called "handles" available at http://www.sysinternals.com/ntw2k/freeware/handle.shtml[^] that can show you open handles. I have examined this executable for the exports it uses but there are a lot of undocumented functions with somewhat ambiquous names.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      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