/// <summary> /// Closes the IO instance, stopping the ability to write and read. /// </summary> public void Close() { //Check if (!Open) { return; } //Close ms.Close(); Out.Close(); In.Close(); }
/// <summary> /// Closes the IO and any open streams. /// </summary> public virtual void Close() { if (Opened) { if (Stream != null) { Stream.Dispose(); } if (In != null) { In.Close(); } if (Out != null) { Out.Close(); } Opened = false; } }
// Making a Method to Display in Main public void CustomerDisplay() { StreamWriter In; try { In = File.AppendText("C:\\Users\\RON TAYLOR\\Desktop\\Computer Programing\\Customer_Information.txt"); Console.WriteLine("please enter customers number"); customernumber = int.Parse(Console.ReadLine()); Console.WriteLine("please enter customers name"); customername = Console.ReadLine(); Console.WriteLine("please enter there address"); address = Console.ReadLine(); In.WriteLine(customernumber); In.WriteLine(customername); In.WriteLine(address); In.WriteLine("CUstomer number :{0} Customer name :{1} Customer address :{2}", customernumber, customername, address); In.Close(); } catch { Console.WriteLine(" file not writtten "); } Console.ReadLine(); StreamReader Fr; Fr = File.OpenText("C:\\Users\\RON TAYLOR\\Desktop\\Computer Programing\\Customer_Information.txt"); infodisplay = Fr.ReadLine(); while (infodisplay != null) { Console.WriteLine(infodisplay); infodisplay = Fr.ReadLine(); } Fr.Close(); }
public static void runnerMain() { if (stdIn) { In = new Reader(Console.OpenStandardInput()); } else { In = new Reader(INPUT_FILE_NAME); } if (stdOut) { Out = new StreamWriter(Console.OpenStandardOutput()); } else { Out = new StreamWriter(OUTPUT_FILE_NAME); } for (int i = 1; i <= NUM_OF_TEST_CASES; i++) { try { run(i); } catch (Exception e) { Out.WriteLine("Exception thrown on test case " + i); Out.WriteLine(e.StackTrace); Out.Flush(); if (crash) { throw new Exception(); } } if (flush) { Out.Flush(); } } In.Close(); Out.Close(); }
/// <summary> /// Close and release all resources used by this client. /// </summary> public void Dispose() { if (!Alive) { Out.Close(); In.Close(); return; } up.WaitOne(); In.Close(); Out.Close(); up.Dispose(); SignalHandler = new Dispatcher <Message>(); if (OnClose != null) { OnClose(); } }
/// <summary> /// 销毁游戏资源 /// </summary> public void Dispose() { if (!mDisposed) { mDisposed = true; if (null != In) { In.Close(); In = null; } if (null != Out) { Out.Close(); Out = null; } if (null != Buffer) { Buffer.Close(); Buffer.Dispose(); Buffer = null; } } }