Re: Checking if file being accessed
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Tue, 10 Jun 2008 20:04:46 -0700
On Tue, 10 Jun 2008 18:38:46 -0700, tshad <tshad@xxxxxxxxxxxxxx> wrote:
[...]
Most unhelpfully, you could find the file
available, but then it could become unavailable by the time you get
to try to open it.
In my case, this wouldn't happen.
Says you.
Unless you have somehow set the file permissions so that only your process has access to the file, you cannot assume in your code that the file will remain unavailable just because at some point in time it was.
I am watching the folder with a
filewatcher Service and the only access would be the person dropping the
file in my folder and my accessing it.
That may be the typical case, even by far. But you can't assume it.
If you want to include some sort of retry logic, so that you can
gracefully deal with situations where something else might also be
using the file, then do so. But once you've successfully opened the
file, just use the opened file. Anything less is just pointless
file-twiddling.
Probably right.
I am still curious as to why the FileShare.none wouldn't create an error, if
the file were still being written to.
It probably doesn't. The most likely reason that the file is inaccessible is because _your_ process has it open, due to the successful call to File.Open(). That's what I said before, and I still believe it. :)
Pete
.
- References:
- Checking if file being accessed
- From: tshad
- Re: Checking if file being accessed
- From: Peter Duniho
- Re: Checking if file being accessed
- From: tshad
- Checking if file being accessed
- Prev by Date: Re: ProgressBar while MDI child form is loading
- Next by Date: Re: Basic Authentication
- Previous by thread: Re: Checking if file being accessed
- Next by thread: Re: Checking if file being accessed
- Index(es):
Relevant Pages
|