Re: Check if TIF file in use

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Are you sure you tried this with FileShare.None specified for the share
argument?

FileShare.None means that you can't open the file if something else has it
open (in any way, shape or form) and, once you have it open, nothing else
can open it untill you close it.

It is what is commonly known as 'opening a file for exclusive use' and it
works reliably.

If the scanner is still writing the file I would expect that you get an
exception when you attempt to open the file in this manner.

If you don't, and the scanner is still writing the file, then it would
indicate that the scanner is opening and closing the file each time it
writes a block.

Because of the critical nature of the file (it is only the entire file that
has any meaning), if anyone who worked for me wrote a piece of code like
that, they would be looking for another job.




"ValK" <ValK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:07638854-170A-4722-87CB-BFB47B96EE03@xxxxxxxxxxxxxxxx
I just tried that too. Didn't work. Still can open file while the scanning.

"Herfried K. Wagner [MVP]" wrote:

"ValK" <ValK@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb:
I'm using FileStream. This is my code example:

Dim fileObj As New System.IO.FileStream(sFile, FileMode.OpenOrCreate,
FileAccess.Write, FileShare.None)

Use 'FileShare.ReadWrite'. The value of this parameter determines which
operations /other processes/ can perform while your application is
accessing
the file.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>




.



Relevant Pages

  • Re: Check if TIF file in use
    ... while the scanner is still writing without any exceptions. ... Canon "Capture Perfect" software is opening and closing the file each time it ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Automatically grant user permission to use USB scanner in F11 x86_64
    ... Itamar Reis Peixoto wrote: ... I hadn't found anything in my searches up to the point of writing the ... the vendor of the scanner isn't listed even though they do have a sane ... Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines ...
    (Fedora)
  • how to find number of processors in python
    ... am writing a scanner using python which has to get the information for ... sun's dual processors, so could any one of you please tell me how to ...
    (comp.lang.python)
  • Re: fopen() question.
    ... note that opening a file for update does not create ... so if you want to open only an existing file for writing you ... opening it again with "r+" if you really do want update mode). ... platform-dependant anyway, you may as well write platform-dependant ...
    (comp.lang.c)
  • Re: module: zipfile.writestr - line endings issue
    ... Maybe the issue lies with this way ) of writing the ... The problem is with how you are opening the file. ... dfile = file ... Python documentation seem to recommend using open. ...
    (comp.lang.python)