// The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources if (this.reader != null) { this.reader.Dispose(); this.reader = null; } if (this.writer != null) { this.writer.Dispose(); this.writer = null; } } }
private FileIOManager(FileInfo fileOnDisk, bool read) { this.FileName = fileOnDisk.FullName; if (read) { if (!fileOnDisk.Exists) { // Better than File.Create as the dispose will release system holds on the file that may linger StreamWriter creationWriter = new StreamWriter(fileOnDisk.FullName); creationWriter.Dispose(); } this.reader = new CustomFileReader(fileOnDisk.FullName); } else { this.writer = new StreamWriter(fileOnDisk.FullName); } }