Hi,
I need to write a .NET application that is monitoring a file on a samba share hosted by a Redhat Linux.
The file is produced by a UNIX script.
The .NET code monitors the file (\\server\share\file.txt) and waits for a specific string to appear in the file.
To do that, I have a simple loop with a ReadAllText:
do {
...
var gp3Output = _fileSystem.ReadAllText(gp3OutputFilePath);
if (!gp3Output.Contains("DOTNET-END-OF-PROCESS"))
{
continue;
}
...
while (...test timeout...);
The problem is that there's caching happening under the hood.
The file is well updated on the linux machine but the changes are not reflected immediatly by ReadAllText.
It takes several iterations to actually see the changes (several minutes).
If I open the same file with notepad, the content is alright and all of a sudden, the .NET code also updates.
Notepad is apparently forcing the cached version of the file to reload.
It's driving me crazy. I've modified the code down to the StreamReader then to plain byte reading from the Stream.
No way to get rid of the caching.
That's probably a caching happening at file system level in windows and maybe related to FAST IO.
Any Idea ?
No comments:
Post a Comment