Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Read a file that is opened by another process

by ady (Deacon)
on Nov 20, 2010 at 13:53 UTC ( [id://872668]=perlquestion: print w/replies, xml ) Need Help??

ady has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

* on MS Windows OS (XP)

I need to read a file that is opened exclusively by another process (FileShare mode None);

Whatever I try, I get a file sharing violation.

It MUST be possibe (ex: I can open the file in Notepad!) - but how...
Any suggestions ?

Thanks, / Allan.

Replies are listed 'Best First'.
Re: Read a file that is opened by another process
by BrowserUk (Patriarch) on Nov 20, 2010 at 14:32 UTC

    If the (windows) share mode was really none, (as in CreateFile/ShareMode == 0), then notepad would not be able to open the file.

    So, first you need to explain what you mean by "FileShare mode None". Ie. how is that file opened and with what parameters?

    Or, what makes you think it has been opened "exclusive" if notepad can also open it?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Sorry, you're right BrowserUk, --
      Let me rephrase the question:

      * assume a file with exclusive access by a process (ex .NET C#: FileStream fs = fi.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);

      * it seems I can't use any Windows API to read that file, - not from managed C# at least, so i tried from Perl, - but I can't find a way here either.

      * and no, Notepad will not open this file.

      But I assume there must be a way, since some backup applications are able to copy files, that are currently opened by other processes ?

        With the appropriate privileges and access to the right APIs this is possible.

        But gaining access to those APIs is far harder from Perl than C or C#, and way beyond the scope of this forum.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found