public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Create a new EndofStreamException instance,string is empty."); try { string expectString = string.Empty; //Create the application domain setup information. EndOfStreamException myEndOfStreamException = new EndOfStreamException(expectString); if (myEndOfStreamException.Message != expectString) { TestLibrary.TestFramework.LogError("002.1", "the EndofStreamException ctor error occurred.the message should be " + expectString); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e); retVal = false; } return(retVal); }
public bool PosTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest3: Create a new EndofStreamException instance,string is null,then its inner exception set to a null reference ."); try { string expectString = null; //Create the application domain setup information. EndOfStreamException myEndOfStreamException = new EndOfStreamException(expectString); if (myEndOfStreamException == null) { TestLibrary.TestFramework.LogError("003.1", "the EndofStreamException ctor error occurred. the message should be null" ); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e); retVal = false; } return retVal; }
internal void ShouldInvalidateServer_should_return_expected_result_for_exceptionType(string exceptionTypeName, bool expectedResult) { _subject.Initialize(); Exception exception; var clusterId = new ClusterId(1); var serverId = new ServerId(clusterId, new DnsEndPoint("localhost", 27017)); var connectionId = new ConnectionId(serverId); var command = new BsonDocument("command", 1); var commandResult = new BsonDocument("ok", 1); switch (exceptionTypeName) { case nameof(EndOfStreamException): exception = new EndOfStreamException(); break; case nameof(Exception): exception = new Exception(); break; case nameof(IOException): exception = new IOException(); break; case nameof(MongoConnectionException): exception = new MongoConnectionException(connectionId, "message"); break; case nameof(MongoNodeIsRecoveringException): exception = new MongoNodeIsRecoveringException(connectionId, command, commandResult); break; case nameof(MongoNotPrimaryException): exception = new MongoNotPrimaryException(connectionId, command, commandResult); break; case nameof(SocketException): exception = new SocketException(); break; default: throw new Exception($"Invalid exceptionTypeName: {exceptionTypeName}."); } var result = _subject.ShouldInvalidateServer(exception); result.Should().Be(expectedResult); }
public static EIB_Adress Parse(string EibAdrString) { Exception ex = new EndOfStreamException("Falsches Format der EIB-Adresse"); EIB_Adress e = null; char[] delimiterChars = { '/', '.' }; String[] parts = EibAdrString.Split(delimiterChars); if (parts.Length != 3) { throw ex; } ushort a = ushort.Parse(parts[0]); ushort b = ushort.Parse(parts[1]); ushort c = ushort.Parse(parts[2]); if (EibAdrString.Contains("/")) { // Gruppenadr e = new EIB_Adress(a, b, c); } else if (EibAdrString.Contains(".")) { // Physik. Adr e = new EIB_Adress(0, EIB_Adress_Typ.PhysAdr); e.Set_PA(a, b, c); } return(e); }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2: Create a new EndofStreamException instance,string is empty."); try { string expectString = string.Empty; //Create the application domain setup information. EndOfStreamException myEndOfStreamException = new EndOfStreamException(expectString); if (myEndOfStreamException.Message != expectString) { TestLibrary.TestFramework.LogError("002.1", "the EndofStreamException ctor error occurred.the message should be " + expectString); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002.2", "Unexpected exception: " + e); retVal = false; } return retVal; }
protected void HandleIOException(Exception e) { // socket error when in negotiation, throw BrokerUnreachableException // immediately if (m_inConnectionNegotiation) { var cfe = new ConnectFailureException("I/O error before connection negotiation was completed", e); throw new BrokerUnreachableException(cfe); } if (++m_missedHeartbeats >= SOCKET_TIMEOUTS_TO_CONSIDER_PEER_UNRESPONSIVE) { var description = String.Format("Peer missed 2 heartbeats with heartbeat timeout set to {0} seconds", m_heartbeat); var eose = new EndOfStreamException(description); m_shutdownReport.Add(new ShutdownReportEntry(description, eose)); HandleMainLoopException(new ShutdownEventArgs(ShutdownInitiator.Library, 0, "End of stream", eose)); TerminateMainloop(); FinishClose(); } }
public void HeartbeatReadLoop() { while (!m_closed) { if (!m_heartbeatRead.WaitOne(Heartbeat * 1000, false)) { m_missedHeartbeats++; } else { m_missedHeartbeats = 0; } // Has to miss two full heartbeats to force socket close if (m_missedHeartbeats > 1) { EndOfStreamException eose = new EndOfStreamException( "Heartbeat missing with heartbeat == " + m_heartbeat + " seconds"); HandleMainLoopException(new ShutdownEventArgs( ShutdownInitiator.Library, 0, "End of stream", eose)); break; } } TerminateMainloop(); FinishClose(); }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new EndOfStreamException instance."); try { //Create the application domain setup information. EndOfStreamException myEndOfStreamException = new EndOfStreamException(); if (myEndOfStreamException == null) { TestLibrary.TestFramework.LogError("001.1", "the EndOfStreamException ctor error occurred. "); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); retVal = false; } return retVal; }
public bool PosTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest3: Create a new EndofStreamException instance,string is null,then its inner exception set to a null reference ."); try { string expectString = null; //Create the application domain setup information. EndOfStreamException myEndOfStreamException = new EndOfStreamException(expectString); if (myEndOfStreamException == null) { TestLibrary.TestFramework.LogError("003.1", "the EndofStreamException ctor error occurred. the message should be null"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e); retVal = false; } return(retVal); }
public void HeartbeatReadTimerCallback(object state) { lock (_heartBeatReadLock) { if (m_hasDisposedHeartBeatReadTimer) { return; } bool shouldTerminate = false; try { if (!m_closed) { if (!m_heartbeatRead.WaitOne(0)) { m_missedHeartbeats++; } else { m_missedHeartbeats = 0; } // We check against 8 = 2 * 4 because we need to wait for at // least two complete heartbeat setting intervals before // complaining, and we've set the socket timeout to a quarter // of the heartbeat setting in setHeartbeat above. if (m_missedHeartbeats > 2 * 4) { String description = String.Format("Heartbeat missing with heartbeat == {0} seconds", m_heartbeat); var eose = new EndOfStreamException(description); ESLog.Error(description, eose); m_shutdownReport.Add(new ShutdownReportEntry(description, eose)); HandleMainLoopException( new ShutdownEventArgs(ShutdownInitiator.Library, 0, "End of stream", eose)); shouldTerminate = true; } } if (shouldTerminate) { TerminateMainloop(); FinishClose(); } else if (_heartbeatReadTimer != null) { _heartbeatReadTimer.Change(Heartbeat * 1000, Timeout.Infinite); } } catch (ObjectDisposedException) { // timer is already disposed, // e.g. due to shutdown } catch (NullReferenceException) { // timer has already been disposed from a different thread after null check // this event should be rare } } }
public static void EndOfStreamException_Ctor_String() { EndOfStreamException i = new EndOfStreamException(exceptionMessage); Assert.Equal(exceptionMessage, i.Message); Assert.Equal(COR_E_ENDOFSTREAM, unchecked ((uint)i.HResult)); }
public static void EndOfStreamException_Ctor_String_Exception() { Exception ex = new Exception(innerExceptionMessage); EndOfStreamException i = new EndOfStreamException(exceptionMessage, ex); Assert.Equal(exceptionMessage, i.Message); Assert.Equal(innerExceptionMessage, i.InnerException.Message); Assert.Equal(ex.HResult, i.InnerException.HResult); Assert.Equal(COR_E_ENDOFSTREAM, unchecked ((uint)i.HResult)); }
// Token: 0x06000265 RID: 613 RVA: 0x00008718 File Offset: 0x00006918 private byte ReadByte() { int num = this.stream.ReadByte(); if (num == -1) { Exception innerException = new EndOfStreamException(); throw new EasWBXmlTransientException("End of stream reached by ReadByte before parsing was complete", innerException); } return((byte)num); }
protected override void Act() { try { _target.Seek(_offset, SeekOrigin.Begin); Assert.Fail(); } catch (EndOfStreamException ex) { _actualException = ex; } }
public void Can_interrupt_BasicConsumer_in_bgthread_by_closing_channel() { RabbitMqConfig.UsingChannel(channel => { string recvMsg = null; EndOfStreamException lastEx = null; var bgThread = new Thread(() => { try { var consumer = new RabbitMqBasicConsumer(channel); channel.BasicConsume(MqQueueNames <HelloRabbit> .Direct, false, consumer); while (true) { try { var e = consumer.Queue.Dequeue(); recvMsg = e.Body.FromUtf8Bytes(); } catch (EndOfStreamException ex) { // The consumer was cancelled, the model closed, or the // connection went away. Console.WriteLine("EndOfStreamException in bgthread: {0}", ex.Message); lastEx = ex; return; } catch (Exception ex) { Assert.Fail("Unexpected exception in bgthread: " + ex.Message); } } } catch (Exception ex) { Console.WriteLine("Exception in bgthread: {0}: {1}", ex.GetType().Name, ex.Message); } }) { Name = "Closing Channel Test", IsBackground = true }; bgThread.Start(); PublishHelloRabbit(channel); Thread.Sleep(100); // closing either throws EndOfStreamException in bgthread channel.Close(); // connection.Close(); Thread.Sleep(2000); Assert.That(recvMsg, Is.Not.Null); Assert.That(lastEx, Is.Not.Null); }); }
internal void ShouldInvalidateServer_should_return_expected_result_for_exceptionType(string exceptionTypeName, bool expectedResult) { _subject.Initialize(); Exception exception; var clusterId = new ClusterId(1); var serverId = new ServerId(clusterId, new DnsEndPoint("localhost", 27017)); var connectionId = new ConnectionId(serverId); var command = new BsonDocument("command", 1); var notWritablePrimaryResult = new BsonDocument { { "code", ServerErrorCode.NotWritablePrimary } }; var nodeIsRecoveringResult = new BsonDocument("code", ServerErrorCode.InterruptedAtShutdown); switch (exceptionTypeName) { case nameof(EndOfStreamException): exception = new EndOfStreamException(); break; case nameof(Exception): exception = new Exception(); break; case nameof(IOException): exception = new IOException(); break; case nameof(MongoConnectionException): exception = new MongoConnectionException(connectionId, "message"); break; case nameof(MongoNodeIsRecoveringException): exception = new MongoNodeIsRecoveringException(connectionId, command, notWritablePrimaryResult); break; case nameof(MongoNotPrimaryException): exception = new MongoNotPrimaryException(connectionId, command, nodeIsRecoveringResult); break; case nameof(SocketException): exception = new SocketException(); break; case "MongoConnectionExceptionWithSocketTimeout": var innermostException = new SocketException((int)SocketError.TimedOut); var innerException = new IOException("Execute Order 66", innermostException); exception = new MongoConnectionException(connectionId, "Yes, Lord Sidious", innerException); break; case nameof(TimeoutException): exception = new TimeoutException(); break; case nameof(MongoExecutionTimeoutException): exception = new MongoExecutionTimeoutException(connectionId, "message"); break; default: throw new Exception($"Invalid exceptionTypeName: {exceptionTypeName}."); } var result = _subject.ShouldInvalidateServer(Mock.Of <IConnection>(), exception, new ServerDescription(_subject.ServerId, _subject.EndPoint), out _); result.Should().Be(expectedResult); }
// Token: 0x0600026A RID: 618 RVA: 0x00008884 File Offset: 0x00006A84 private string ReadInlineString() { long position = this.stream.Position; int num = 0; int num2 = 0; byte[] array = null; string @string; try { byte[] array2; array = (array2 = WBXmlReader.readerPool.Acquire()); for (;;) { int num3 = this.stream.Read(array2, num, array2.Length - num); if (num3 == 0) { break; } num2 += num3; while (num < num2 && array2[num] != 0) { num++; } if (num < num2) { goto Block_5; } Array.Resize <byte>(ref array2, array2.Length * 2); } Exception innerException = new EndOfStreamException(); throw new EasWBXmlTransientException("End of stream reached by ReadInlineString before parsing was complete", innerException); Block_5: this.stream.Seek(position + (long)num + 1L, SeekOrigin.Begin); @string = Encoding.UTF8.GetString(array2, 0, num); } finally { if (array != null) { WBXmlReader.readerPool.Release(array); } } return(@string); }
// Token: 0x06000266 RID: 614 RVA: 0x0000874C File Offset: 0x0000694C private void ReadBytes(byte[] answer) { int num = answer.Length; int i; int num2; for (i = 0; i < num; i += num2) { num2 = this.stream.Read(answer, i, num - i); if (num2 == 0) { break; } } if (i != num) { Exception innerException = new EndOfStreamException(); throw new EasWBXmlTransientException("End of stream reached by ReadBytes before parsing was complete", innerException); } }
public void HeartbeatReadTimerCallback(object state) { var shouldTerminate = false; if (!m_closed) { if (!m_heartbeatRead.WaitOne(0, false)) { m_missedHeartbeats++; } else { m_missedHeartbeats = 0; } // Has to miss two full heartbeats to force socket close if (m_missedHeartbeats > 1) { String description = "Heartbeat missing with heartbeat == " + m_heartbeat + " seconds"; EndOfStreamException eose = new EndOfStreamException(description); m_shutdownReport.Add(new ShutdownReportEntry(description, eose)); HandleMainLoopException(new ShutdownEventArgs( ShutdownInitiator.Library, 0, "End of stream", eose)); shouldTerminate = true; } } if (shouldTerminate) { TerminateMainloop(); FinishClose(); } else { heartbeatReadTimer.Change(Heartbeat * 1000, Timeout.Infinite); } }
// Use the WriteBase64 method to create an XML document. The object // passed by the user is encoded and included in the document. public static void EncodeXmlFile(string xmlFileName, FileStream fileOld) { var buffer = new byte[bufferSize]; int readByte = 0; var xw = new XmlTextWriter(xmlFileName, Encoding.UTF8); xw.WriteStartDocument(); xw.WriteStartElement("root"); // Create a Char writer. var br = new BinaryReader(fileOld); // Set the file pointer to the end. try { do { readByte = br.Read(buffer, 0, bufferSize); xw.WriteBase64(buffer, 0, readByte); } while (bufferSize <= readByte); } catch (Exception ex) { var ex1 = new EndOfStreamException(); if (ex1.Equals(ex)) { Console.WriteLine("We are at end of file"); } else { Console.WriteLine(ex); } } xw.WriteEndElement(); xw.WriteEndDocument(); xw.Flush(); xw.Close(); }
public void TestWritePastEnd() { MemoryMappedFile mmf = MemoryMappedFile.CreateInMemoryMap(); Assert.IsNotNull(mmf); EndOfStreamException expected = null; mmf.Position = MemoryMappedFile.DefaultInMemoryMapSize - 5; byte[] buffer = new byte[10]; try { mmf.Write(buffer, 0, buffer.Length); } catch (EndOfStreamException ex) { expected = ex; } Assert.IsNotNull(expected); }
///<summary>Closes this Subscription, cancelling the consumer ///record in the server.</summary> public void Close() { try { bool shouldCancelConsumer = false; if (m_consumer != null) { shouldCancelConsumer = m_consumer.IsRunning; m_consumer = null; } if (shouldCancelConsumer) { if (Model.IsOpen) { Model.BasicCancel(ConsumerTag); } ConsumerTag = null; } m_queueCts.Cancel(true); if (m_queue != null) { m_queue.Dispose(); m_queue = null; } #if NETFX_CORE || NET4 var exn = new EndOfStreamException("Subscription closed"); foreach (var tsc in m_waiting) { tsc.TrySetException(exn); } #endif } catch (OperationInterruptedException) { // We don't mind, here. } }
public void HeartbeatReadTimerCallback(object state) { bool shouldTerminate = false; if (!m_closed) { if (!m_heartbeatRead.WaitOne(0)) { m_missedHeartbeats++; } else { m_missedHeartbeats = 0; } // We check against 8 = 2 * 4 because we need to wait for at // least two complete heartbeat setting intervals before // complaining, and we've set the socket timeout to a quarter // of the heartbeat setting in setHeartbeat above. if (m_missedHeartbeats > 2 * 4) { String description = String.Format("Heartbeat missing with heartbeat == {0} seconds", m_heartbeat); var eose = new EndOfStreamException(description); m_shutdownReport.Add(new ShutdownReportEntry(description, eose)); HandleMainLoopException( new ShutdownEventArgs(ShutdownInitiator.Library, 0, "End of stream", eose)); shouldTerminate = true; } } if (shouldTerminate) { TerminateMainloop(); FinishClose(); } else { _heartbeatReadTimer.Change(Heartbeat * 1000, Timeout.Infinite); } }
internal static bool ShouldWrap(Exception exception, out Status status) { if (exception is RpcException) { status = default; return(false); } status = new Status(exception switch { #pragma warning disable IDE0059 // needs more recent compiler than the CI server has OperationCanceledException a => StatusCode.Cancelled, ArgumentException b => StatusCode.InvalidArgument, NotImplementedException c => StatusCode.Unimplemented, NotSupportedException d => StatusCode.Unimplemented, SecurityException e => StatusCode.PermissionDenied, EndOfStreamException f => StatusCode.OutOfRange, FileNotFoundException g => StatusCode.NotFound, DirectoryNotFoundException h => StatusCode.NotFound, TimeoutException i => StatusCode.DeadlineExceeded, #pragma warning restore IDE0059 // needs more recent compiler than the CI server has _ => StatusCode.Unknown, }, exception.Message, exception);
public static void RecvCallback(IAsyncResult ar) { UDPSocketStateObject state = (UDPSocketStateObject)ar.AsyncState; try { int bytesRead = state.socket.EndReceiveFrom(ar, ref state.remote); if (bytesRead <= 0) { var ex = new EndOfStreamException("socket closed by peer"); state.obj.PushError(ex); return; } var data = new byte[bytesRead]; Buffer.BlockCopy(state.buf, 0, data, 0, bytesRead); state.obj.PushToRecvQueue(data); state.obj.PostReadRequest(state); } catch (SocketException ex) { state.obj.PushError(ex); } }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new EndOfStreamException instance."); try { //Create the application domain setup information. EndOfStreamException myEndOfStreamException = new EndOfStreamException(); if (myEndOfStreamException == null) { TestLibrary.TestFramework.LogError("001.1", "the EndOfStreamException ctor error occurred. "); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e); retVal = false; } return(retVal); }
public void Can_interrupt_BasicConsumer_in_bgthread_by_closing_channel() { using (IConnection connection = mqFactory.CreateConnection()) using (IModel channel = connection.CreateModel()) { string recvMsg = null; EndOfStreamException lastEx = null; var bgThread = new Thread(() => { try { var consumer = new QueueingBasicConsumer(channel); channel.BasicConsume(QueueNames <HelloRabbit> .In, noAck: false, consumer: consumer); while (true) { try { var e = consumer.Queue.Dequeue(); recvMsg = e.Body.FromUtf8Bytes(); } catch (EndOfStreamException ex) { // The consumer was cancelled, the model closed, or the // connection went away. "EndOfStreamException in bgthread: {0}".Print(ex.Message); lastEx = ex; return; } catch (Exception ex) { Assert.Fail("Unexpected exception in bgthread: " + ex.Message); } } } catch (Exception ex) { "Exception in bgthread: {0}: {1}".Print(ex.GetType().Name, ex.Message); } }) { Name = "Closing Channel Test", IsBackground = true, }; bgThread.Start(); PublishHelloRabbit(channel); Thread.Sleep(100); //closing either throws EndOfStreamException in bgthread channel.Close(); //connection.Close(); Thread.Sleep(2000); Assert.That(recvMsg, Is.Not.Null); Assert.That(lastEx, Is.Not.Null); "EOF...".Print(); } }
public static void EndOfStreamException_Ctor1() { EndOfStreamException i = new EndOfStreamException(); Assert.Equal(COR_E_ENDOFSTREAM, (uint)i.HResult); }
public static void ThrowIfNecessary( this Error error, [CanBeNull] Func <Error, string> message = null) { if (error == Error.Ok) { return; } var code = Enum.GetName(typeof(Error), error); var arg = message?.Invoke(error) ?? $"Operation failed with code: '{code}(error)'"; Exception exception; switch (error) { case Error.Unauthorized: case Error.FileNoPermission: exception = new UnauthorizedAccessException(arg); break; case Error.ParameterRangeError: exception = new ArgumentOutOfRangeException(null, arg); break; case Error.OutOfMemory: exception = new OutOfMemoryException(arg); break; case Error.FileBadDrive: case Error.FileBadPath: case Error.FileNotFound: exception = new FileNotFoundException(arg); break; case Error.FileAlreadyInUse: case Error.FileCantOpen: case Error.FileCantRead: case Error.FileCorrupt: case Error.FileMissingDependencies: case Error.FileUnrecognized: exception = new FileLoadException(arg); break; case Error.FileEof: exception = new EndOfStreamException(arg); break; case Error.FileCantWrite: case Error.CantAcquireResource: case Error.CantOpen: case Error.CantCreate: case Error.AlreadyInUse: case Error.Locked: exception = new IOException(arg); break; case Error.Timeout: exception = new TimeoutException(arg); break; case Error.InvalidData: exception = new InvalidDataException(arg); break; case Error.InvalidParameter: exception = new ArgumentException(null, arg); break; default: exception = new InvalidOperationException(arg); break; } throw exception; }
public static void EndOfStreamException_Ctor_Empty() { EndOfStreamException i = new EndOfStreamException(); Assert.Equal(COR_E_ENDOFSTREAM, unchecked ((uint)i.HResult)); }
private static void getException(ILogger logger, EndOfStreamException exception) { logger.LogError(exception.ToString()); taskCompletionSource.SetException(new InvalidOperationException("'npm run serve' failed.", exception)); }
private static EmberException CreateEmberException(EndOfStreamException ex) => new EmberException("Unexpected end of stream.", ex);
/// <summary> /// Loads a font from the specified font definition TextAsset /// and adds it to the font store. /// </summary> /// <param name="fontDef">The TextAsset that defines the font.</param> public void Load(TextAsset def) { if (def == null) { return; } //Binary BM font support Stream stream = new MemoryStream(def.bytes); BinaryReader br = new BinaryReader(stream); byte[] magicString = br.ReadBytes(4); if (Encoding.UTF8.GetString(magicString).Equals("BMF" + (char)3)) { char blockType; int blockSize; fontDef = def; while (true) { try { blockType = br.ReadChar(); blockSize = br.ReadInt32(); switch (blockType) { case (char)1: ReadInfoBlock(br, blockSize); break; case (char)2: ReadCommonBlock(br, blockSize); break; case (char)3: ReadPagesBlock(br, blockSize); break; case (char)4: ReadCharsBlock(br, blockSize); break; case (char)5: ReadKerningPairsBlock(br, blockSize); break; default: Debug.Log("Unexpected block type " + (int)blockType); break; } } catch (EndOfStreamException eose) { EndOfStreamException dummy = eose; eose = dummy; break; } } } else { int pos, c = 0; fontDef = def; string[] lines = fontDef.text.Split(new char[] { '\n' }); pos = ParseSection("info", lines, HeaderParser, 0); pos = ParseSection("common", lines, CommonParser, pos); pos = ParseSection("chars count", lines, CharCountParser, pos); while (pos < lines.Length && c < chars.Length) { if (CharParser(lines[pos++], c)) { ++c; } } // Tally another character pos = ParseSection("kernings count", lines, KerningCountParser, pos); c = 0; while (pos < lines.Length && c < kerningsCount) { if (KerningParser(lines[pos++])) { ++c; } } } // Tally another kerning // Now apply any character spacing // (setting it temporarily to another // value incase this was set in-script // before the file was parsed): float tempSpacing = charSpacing; charSpacing = 0; CharacterSpacing = tempSpacing; br.Close(); stream.Close(); stream.Dispose(); }