Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 892544 - Last Review: December 3, 2007 - Revision: 2.2
FIX: You receive exception error messages when you use the StreamWriter.Flush () method or the StreamWriter.Close () method to access a file on a disk that has insufficient space in .NET Framework 1.1
On This Page
SYMPTOMS
On a computer that is running Microsoft .NET Framework 1.1, when you use the
StreamWriter.Flush() method or the
StreamWriter.Close() method to access a file on a disk that has insufficient space, you receive the following exception error message:
System.IO.IOException: There is not enough space on the
disk.
After you free up space on the disk and then try to access the file again, you receive the following exception error message:
System.IO.IOException: The process cannot
access the file "C:\outputTest.txt" because it is being used by another
process.
CAUSE
This problem occurs if the common language runtime (CLR) does not close the file handle after you receive the first exception error message. If the file handle does not close, you cannot access the file regardless of how much space is on the disk.
RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Service Pack that contains this hotfix.
To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the
Time Zone tab in the Date and Time tool in Control Panel.
Date Time Version Size File name
----------------------------------------------------------
24-Feb-2005 11:50 1.1.4322.2064 2,138,112 Mscorlib.dll
24-Feb-2005 11:50 10,912 Mscorlib.ldo
25-Feb-2005 03:50 1.1.4322.2064 2,519,040 Mscorsvr.dll
25-Feb-2005 03:51 1.1.4322.2064 2,506,752 Mscorwks.dll
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed in the "Applies to" section.
Steps to reproduce the problem
- Start Microsoft Visual Studio .NET 2003.
- On the Start Page menu, click New Project.
- In the New Project window, click Visual C# Project, click Windows Application, and then click OK.
- In Solution Explorer, right-click Form1.cs, and then click View Code.
- Replace the code in Form1.cs with the following code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(120, 88);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Test";
this.button1.Click += new System.EventHandler(this.button1_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
System.IO.TextWriter _textWriter;
try
{
//initializing textWriter
_textWriter =
new StreamWriter( @"Drive:\outputTest.txt",true,Encoding.Default );
}
catch( Exception exInit )
{
MessageBox.Show(exInit.ToString());
return;
}
string str = new String( 'a', 100 );
try
{
for( int i=0; i<100; i++ )
{
_textWriter.WriteLine( "{0}:{1}", i, str );
_textWriter.Flush();
}
MessageBox.Show( "file created" );
}
catch( Exception ex )
{
MessageBox.Show(ex.ToString());
return;
}
finally
{
try
{
// closing file object
_textWriter.Close();
}
catch( Exception ex )
{
MessageBox.Show(ex.ToString());
}
finally
{
_textWriter = null;
}
}
}
}
} Note The placeholder Drive is a placeholder for the disk
that has insufficient space. - Press CTRL+F5 to run the application that you created in step 2.
- Click Test. You will receive the following
exception error message two times:
System.IO.IOException: There is
not enough space on the disk.
- Run the Disk Cleanup wizard (Cleanmgr.exe) to free hard disk space.
- Click
Test again. You will receive the following exception error message:
System.IO.IOException: The process cannot access the file
"Drive:\outputTest.txt" because it is being used by
another process.
APPLIES TO
- Microsoft .NET Framework 1.1 Service Pack 1
- Microsoft .NET Framework 1.1
| kbqfe kbhotfixserver kberrmsg kbprogramming kbvs kbwindowsforms kbfix KB892544 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please