Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How do I test to see if another process is writing to a file (in Windows) (!share)

by jmurphy (Acolyte)
on Sep 25, 2007 at 07:37 UTC ( [id://640870]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I test to see if another process is writing to a file (in Windows) (!share)
in thread How do I test to see if another process is writing to a file (in Windows)

Tye,

Thanks for the pointer. This is exactly what I needed. However, I'm having problems using createFile. If I open the file "a.out" in an editor (Textpad or Notepad) and then run the following:

#!/usr/bin/perl -w use strict; use Win32API::File 0.08 qw( :ALL ); my $status = createFile( "a.out", "w ke", "r" ) or die "Can't get exc +lusive access to file: $^E\n"; if ( $status ) { print "Got it!\n"; }
$status is always true. I can't get createFile to "die". Any ideas?

Thanks,
Jay

  • Comment on Re^2: How do I test to see if another process is writing to a file (in Windows) (!share)
  • Download Code

Replies are listed 'Best First'.
Re^3: How do I test to see if another process is writing to a file (in Windows) (!share)
by tye (Sage) on Sep 25, 2007 at 07:46 UTC

    I guess the interactions are a bit different than my expectations. I get the same results. Worse, once I get the exclusive access, the other process still has the file open for write access but its attempts to write to the file fail.

    So, instead, don't share "r" access and you can tell if anything has the file open at all, it seems.

    - tye        

Re^3: How do I test to see if another process is writing to a file (in Windows) (!share)
by goibhniu (Hermit) on Sep 27, 2007 at 15:47 UTC

    I'm not so sure that having a file in Notepad marks the file in use. I can open the same file over and over again in Notepad. Did you try something with more "bloat" like Word?


    I humbly seek wisdom.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://640870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 19:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found