S
SteMc
Help!
One day I'm writing a program and it's working wonderully, co-operating
nicely. The next day I change nothing but it throws up a file i/o error
and I can't work out why
I have a streamreader and a streamwriter. The reader is set to the
current html file in a borowser window and the writer is a file called
"temp.txt". I close them and then change them round so the reader is
the temp file and the writer the html file. The reader works fine but
the writer claims the file is in use, despite me having just closed it.
The essential bits of the code are as follows
<code>
Dim reading_file As StreamReader = New
StreamReader(central_file_location + "html files\" + _
AxWebBrowser1.LocationName + ".html") {this opens a file called
"0.html"}
Dim writing_file As StreamWriter = New
StreamWriter(central_file_location + "html files\" + _ "temp.txt")
reading_file.Close()
writing_file.Close()
reading_file = New StreamReader(central_file_location + "html files\" +
"temp.txt")
writing_file = New StreamWriter(central_file_location + "html files\" +
_ AxWebBrowser1.LocationName + ".html") {0.html}
<code end>
the error message I get is...
<error message>
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"C:\Documents and Settings\Ste\My Documents\Steve\Ongoing Projects\New
Expert System\html files\0.html" because it is being used by another
process.
<error message end>
Why would this happen? Surely by closing the file it should be free to
open again? I've tried using the object window to see if the reader is
still asigned to the file in question but it gives me info that doesn't
help.
The closing of the file isn't in a loop, after stepping through the
code the closing of the file has definately occured
anyhelp is appreciated,
Steve
One day I'm writing a program and it's working wonderully, co-operating
nicely. The next day I change nothing but it throws up a file i/o error
and I can't work out why

I have a streamreader and a streamwriter. The reader is set to the
current html file in a borowser window and the writer is a file called
"temp.txt". I close them and then change them round so the reader is
the temp file and the writer the html file. The reader works fine but
the writer claims the file is in use, despite me having just closed it.
The essential bits of the code are as follows
<code>
Dim reading_file As StreamReader = New
StreamReader(central_file_location + "html files\" + _
AxWebBrowser1.LocationName + ".html") {this opens a file called
"0.html"}
Dim writing_file As StreamWriter = New
StreamWriter(central_file_location + "html files\" + _ "temp.txt")
reading_file.Close()
writing_file.Close()
reading_file = New StreamReader(central_file_location + "html files\" +
"temp.txt")
writing_file = New StreamWriter(central_file_location + "html files\" +
_ AxWebBrowser1.LocationName + ".html") {0.html}
<code end>
the error message I get is...
<error message>
An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"C:\Documents and Settings\Ste\My Documents\Steve\Ongoing Projects\New
Expert System\html files\0.html" because it is being used by another
process.
<error message end>
Why would this happen? Surely by closing the file it should be free to
open again? I've tried using the object window to see if the reader is
still asigned to the file in question but it gives me info that doesn't
help.
The closing of the file isn't in a loop, after stepping through the
code the closing of the file has definately occured

anyhelp is appreciated,
Steve