Explorar el Código

2002-05-10 Nick Drochak <[email protected]>

	* StreamWriter.cs (Flush): Throw proper exception if internal stream
	has already been closed when we try to flush.

svn path=/trunk/mcs/; revision=4479
Nick Drochak hace 24 años
padre
commit
cc3463e338

+ 5 - 0
mcs/class/corlib/System.IO/ChangeLog

@@ -1,3 +1,8 @@
+2002-05-10  Nick Drochak  <[email protected]>
+
+	* StreamWriter.cs (Flush): Throw proper exception if internal stream
+	has already been closed when we try to flush.
+
 2002/05/10  Nick Drochak <[email protected]>
 
 	* FileNotFoundException.cs (ToString): Don't try to use the inner

+ 10 - 2
mcs/class/corlib/System.IO/StreamWriter.cs

@@ -11,12 +11,13 @@ using System.Text;
 
 namespace System.IO {
 	
-		[Serializable]
+	[Serializable]
         public class StreamWriter : TextWriter {
 
 		private Encoding internalEncoding;
 
 		private Stream internalStream;
+		private bool closed = false;
 
 		private bool iflush;
 		
@@ -118,6 +119,9 @@ namespace System.IO {
 
 		public override void Flush ()
 		{
+			if (closed)
+				throw new ObjectDisposedException("TextWriter");
+
 			internalStream.Flush ();
 		}
 		
@@ -140,7 +144,11 @@ namespace System.IO {
 			Write (value.ToCharArray (), 0, value.Length);
 		}
 
-                         
+		public override void Close()
+		{
+			Dispose(true);
+			closed = true;
+		}
         }
 }