“Object can be disposed of more than once” error
问题 When I run code analysis on the following chunk of code I get this message: Object 'stream' can be disposed more than once in method 'upload.Page_Load(object, EventArgs)'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object. using(var stream = File.Open(newFilename, FileMode.CreateNew)) using(var reader = new BinaryReader(file.InputStream)) using(var writer = new BinaryWriter(stream)) { var chunk = new byte[ChunkSize]; Int32 count;