473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

File IO methods causing locked process errors

I have a program that takes a single text file, reads thru it, finds a break
point based on information in the file and then outputs a single file, then
continues the process.

The end result is many smaller files from one large file.
I'm using the StreamReader and StreamWriter classes from System.IO to
accomplish this.

On my main form I have some text boxes that allow me to enter a date and the
code uses it to determine which original file to process into smaller ones.
I click a command button and the process starts.

Since my smaller files are all output to the same folder, I delete the files
from the previous run prior to starting a new one.

The problem I'm getting is that I can't seem to get all the files deleted
without catching an exception on a few of them which states that the file is
in use by another process. I can't seem to determine why it thinks these
files are in use. I'm calling .close() on the reader and writer and also
setting them both to =Nothing

The only way I can get it to run correctly is to completely close the
application then re-open it. I'm assuming there's some sort reference to
these files that's only being cleared when the application closes. How can
I call these clearing methods from within the application?

Thanks for any responses. If more information is needed or I need to post
some code let me know.




Nov 20 '05 #1
2 1077
As well as calling .Close on the Reader/Writer's I would .Dispose of
them also. This should allow all references to clear.

HTH

David

"Chad Dore'" <ch******@NOSPAM.opelousasgeneral.com> wrote in message
news:pk********************@news.easynews.com:
I have a program that takes a single text file, reads thru it, finds a
break
point based on information in the file and then outputs a single file,
then
continues the process.

The end result is many smaller files from one large file.
I'm using the StreamReader and StreamWriter classes from System.IO to
accomplish this.

On my main form I have some text boxes that allow me to enter a date and
the
code uses it to determine which original file to process into smaller
ones.
I click a command button and the process starts.

Since my smaller files are all output to the same folder, I delete the
files
from the previous run prior to starting a new one.

The problem I'm getting is that I can't seem to get all the files
deleted
without catching an exception on a few of them which states that the file
is
in use by another process. I can't seem to determine why it thinks
these
files are in use. I'm calling .close() on the reader and writer and
also
setting them both to =Nothing

The only way I can get it to run correctly is to completely close the
application then re-open it. I'm assuming there's some sort reference
to
these files that's only being cleared when the application closes. How
can
I call these clearing methods from within the application?

Thanks for any responses. If more information is needed or I need to
post
some code let me know.


Nov 20 '05 #2
Yeah I was going to try that but it said dispose() was not accessible in
this context because its "Protected"

I'll do some more reading in the meantime.

<David Williams>; "VB.NET MVP" <da********************@earthlink.net> wrote
in message news:e9**************@TK2MSFTNGP10.phx.gbl...
As well as calling .Close on the Reader/Writer's I would .Dispose of
them also. This should allow all references to clear.

HTH

David

"Chad Dore'" <ch******@NOSPAM.opelousasgeneral.com> wrote in message
news:pk********************@news.easynews.com:
I have a program that takes a single text file, reads thru it, finds a
break
point based on information in the file and then outputs a single file,
then
continues the process.

The end result is many smaller files from one large file.
I'm using the StreamReader and StreamWriter classes from System.IO to
accomplish this.

On my main form I have some text boxes that allow me to enter a date and
the
code uses it to determine which original file to process into smaller
ones.
I click a command button and the process starts.

Since my smaller files are all output to the same folder, I delete the
files
from the previous run prior to starting a new one.

The problem I'm getting is that I can't seem to get all the files
deleted
without catching an exception on a few of them which states that the file is
in use by another process. I can't seem to determine why it thinks
these
files are in use. I'm calling .close() on the reader and writer and
also
setting them both to =Nothing

The only way I can get it to run correctly is to completely close the
application then re-open it. I'm assuming there's some sort reference
to
these files that's only being cleared when the application closes. How
can
I call these clearing methods from within the application?

Thanks for any responses. If more information is needed or I need to
post
some code let me know.

Nov 20 '05 #3

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

Similar topics

6
by: Pekka Niiranen | last post by:
Hi, I have used the following example from win32 extensions: -----SCRIPT STARTS---- import win32file import win32con import win32security import pywintypes
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
4
by: Earth Worm Jim | last post by:
I am using VS.Net 2003 on Windows 2003 Server (standard edition) and I am getting "The process cannot access the file because it is being used by another process" on DLL's in a VS.Net solution. ...
5
by: Fabio R. | last post by:
To support a webfarm scenario, I'd like to store a global array (serialized) in a file on a network share. In this array there is a list of pages "locked" by other users so I need to read this...
1
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
8
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; I copied a new set of files over to my ASP.NET dir (and subdirs) on our test server. This replaced every file for the app. When I first then tried to bring it up, I got the below error. ...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.