Saturday, March 24, 2012

Open a log file such that another process can delete or rename it

Hi,
How can I open and read a text file such that other process can rename or delete the file while I am still reading it .
Currently, I am making FIleStream object with these parameters

FileStream fs = new FileStream(@dotnet.itags.org."c:\test.txt",FileMode.Open,FileAccess.Read, FileShare.ReadWrite);
but that does'nt let other processes to delete the file
All FileShare shows in intellisense is Read, ReadWrite, Write, None, Inheritable. I did'nt see any FileShare.Delete
I am using .net framework 1.1

You might have to open the file then read the whole contents into a variable and process that. I don't see how you can delete or rename a file while there is a stream reading it.

0 comments:

Post a Comment