473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Stroppy Porgram

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

Mar 12 '06 #1
2 799
What about your writer? Does it have the file open as well?

Also, perhaps your permissions in the suggested folder are bogus.
Try something more general and see if it still bugs out.

Steven Nagy

Mar 13 '06 #2
Fixed it. I think maybe I should put a dunces hat on :(

The sub that the above code is in has been called by another procedure.
In the parent procedure the file in question has been opened and not
closed before calling the new procedure. So the debugger is right when
it says the file is still in use.

What I don't understand now though is why in the child procedure an
instance of a file can be opened and closed once (despite the file
being open and in sue to start with) but not twice?

Thanks for your help though,

Steve

Mar 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: warstar | last post by:
Hello all, I'm in a bit of a problem I'm given a project making an online shopping system for a professional barbershop. But I'm with a small problem in witch language to make the system. My...
1
by: Alan J. Flavell | last post by:
What are the theoretical and practical limits on the length of a GET query string, currently? Strange to say, I found this rather simple question hard to answer, possibly because of searching...
5
by: phickman | last post by:
Hi all. After several searches using Google, I had just about given up on finding a way to clear the console Window. After spending the past week learning assembly language and writing a small...
8
by: Stefano Del Furia | last post by:
Hi all, i have downloaded and installed the new version of C# and VB inside the Visual Studio.NET 2005 suite (beta) I have try to build some simple test's program and i have found that in VB i...
16
by: jimjim | last post by:
#include <stdio.h> #include <stdlib.h> //WARNING: The function's signature should be: f( int ** ) void f(int *ip) { static int dummy = 5; *ip = &dummy; } int main(){
11
by: anon | last post by:
Borland's BGI graphics library (GRAPHICS.LIB, GRAPHICS.TPU) has a bug which can cause the floodfill routine to crash. It's most likely to occur in C applications when compiled using the small data...
2
by: JC | last post by:
I'm looking for help creating a keylogger program.It doesn't have to be hidden because I want to allow people access to what they have written. Can anyone help me with this or send me tutorials or...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
14
by: qatarya3sal | last post by:
*** This is the first form i called it Form1?****** ********************************************************** Imports System.Xml Imports System.IO Public Class Form1 Inherits...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.