I write application which continously reads and rewrites files (this program converts web links in htm files to local links, because I want use this files offline). When I wrote procedure:
// index.htm FileName = (string)kolekcjaPlikow.GetValue(0); StreamReader myStreamReader = null; myStreamReader = File.OpenText(FileName); bufor = myStreamReader.ReadToEnd(); myReadBufor = bufor; myStreamReader.Close(); (2) StreamWriter myStreamWriter = null; myStreamWriter = File.CreateText(FileName); (1)
I get error:
The process cannot access the file 'index.htm' in line (1) because it is being used by another process.
I cannot understand this: why myStreamReader.Close() in line (2) will not release the handle? Is there any possibility release this handle?