Browse Source

Close wrapped file when disposing a File.Stream

Matt Benic 9 years ago
parent
commit
c1ba104b14
1 changed files with 11 additions and 0 deletions
  1. 11 0
      Script/AtomicNET/AtomicNET/IO/File.cs

+ 11 - 0
Script/AtomicNET/AtomicNET/IO/File.cs

@@ -112,6 +112,17 @@ namespace AtomicEngine
 
                 file.Write(buffer, offset, count);
             }
+
+            protected override void Dispose(bool disposing)
+            {
+                if (file != null)
+                {
+                    file.Close();
+                    file = null;
+                }
+
+                base.Dispose(disposing);
+            }
         }
 
         public System.IO.Stream ToStream()