in c#, 2 processes reading minute same file, best proceed prevaricate slight locking exceptions?


with following record reading code:



using (filestream filestream = new filestream(filename, filemode.open, fileaccess.read, fileshare.none))
{
controlling (textreader tr = new streamreader(filestream))
{
twine filecontents = tr.readtoend();
}
}


and following record code:



using (textwriter tw = new streamwriter(filename))
{
tw.write(filecontents);
tw.close();
}


the following difference sum seen:




the slight can't opening file
'c:\temp\myfile.txt' since is
being used another process.




what best proceed avoiding this? does reader need retry on receipt difference there improved way?



note reader slight controlling filesystemwatcher know record changed.



also note that, instance, i'm not looking alternatives ways pity strings between 2 processes.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?