
Signature
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
> > Is there a simple way to find out
> > (1.) when a file is in use,
[quoted text clipped - 5 lines]
>
> Exception will be arised
The problem is that in one directory there are data files and files that
contain all sorts of parameters, that are used by all sorts of shared
methods. So just using a FileShare parameter of the data files per
se won't do. The only thing I can think of conceptually, is ascertaining
whether the directory is in use or not, and blocking use of the data
files of it is. However, I am unable to conceive a method for doing that.
Adrian.
Willy Denoyette [MVP] - 15 Nov 2006 15:00 GMT
| > > Is there a simple way to find out
| > > (1.) when a file is in use,
[quoted text clipped - 15 lines]
| whether the directory is in use or not, and blocking use of the data
| files of it is. However, I am unable to conceive a method for doing that.
There is no such thing like "Directory in use". If you want shared access to
files in an application, you have to open the files for shared read or
read/write access. For files shared for read-only access, there is nothing
special to be done, for files opened in R/W access mode you need to
coordinate the write accesses across the process boundaries, one way to do
this is by using a global mutex. If you wan't finer grained write access
control, you will have to lock file regions using FileStream.Lock/Unlock.
Willy.
> Adrian < - 15 Nov 2006 15:19 GMT
> | > > Is there a simple way to find out
> | > > (1.) when a file is in use,
[quoted text clipped - 25 lines]
>
> Willy.
***********************
Thank you,
Adrian.
> Adrian < - 15 Nov 2006 16:05 GMT
Can't I simply put
After a filestream fs has been opened for read:
while(!fs.CanRead){}
After a filestream fs has been opened for write:
while(!fs.CanWrite){}
Adrian