Home All Groups Group Topic Archive Search About

FileShare Mode in FileStream

Author
26 Jun 2006 6:49 AM
Abhidy
Hi!,
I am doing some fllestream related operation.Multiple instances of my
application are accessing a file(lets say FILE_1).First application will get
read/write access to the file FILE_1 and remaing application will have only
read access.For this purpose i am using this logic

For First Process:

1) FileStream fs =
OpenStream(path,FileMode.OpenOrCreate,FileAccess.ReadWrite,FileShare.Read);
---------------------------------------------------------------------------------
For All other processes:
2) FileStream fs =
OpenStream(path,FileMode.Open,FileAccess.Read,FileShare.Read);

For all other processes I am always getting "File is used by another process
" exception.

Will somebody tell me what wrong things I am doing and how to implement my
above mentioned logic?

AddThis Social Bookmark Button