From a8227888b6db74c48ce556a973393ac91b89167d Mon Sep 17 00:00:00 2001 From: 2 <2@S6305-14> Date: Sat, 10 Oct 2026 15:32:15 +0700 Subject: [PATCH] file streams --- ConsoleCore/Program.cs | 6 +++++- ConsoleCore/RobotFiler.cs | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ConsoleCore/Program.cs b/ConsoleCore/Program.cs index cb2eedb..96f7746 100644 --- a/ConsoleCore/Program.cs +++ b/ConsoleCore/Program.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using ClassLib000.Chess; using ClassLib000.TestModel; using ClassLib000.Walker; @@ -20,6 +21,7 @@ namespace ConsoleCore //ChessConsoler.ChessRedrawBoard(game); //ChessConsoler.ChessRedrawBrokenFigures(game); + /* Appartment app = new Appartment(); app.InitRoom(0, 0, 10, 4); app.InitVC(); @@ -27,7 +29,9 @@ namespace ConsoleCore RobotConsoler.DrawRoom(app); System.Collections.Generic.List arWeekDirty = app.GetDirtyCleanSpace(7); - + */ + RobotFiler.WriteLargeStream(Path.Combine(".", "tmp.txt"), 1); + RobotFiler.WriteLargeText(Path.Combine(".", "tmp.txt"), 1); } diff --git a/ConsoleCore/RobotFiler.cs b/ConsoleCore/RobotFiler.cs index 0703be4..00f5dca 100644 --- a/ConsoleCore/RobotFiler.cs +++ b/ConsoleCore/RobotFiler.cs @@ -16,5 +16,46 @@ namespace ConsoleCore // byte[] bt = Encoding.UTF8.GetBytes(app.GetContent()); // File.WriteAllBytes(sFileName, bt); } + + internal static void WriteLargeStream(string sFileName, int gb) + { + byte[] bt = new byte[] { 67, 67, 67 }; + using (Stream file = File.Create(sFileName, 1024 * 64, FileOptions.DeleteOnClose)) + { + DateTime dtFrom = DateTime.Now; + Console.WriteLine($"{dtFrom:HHmmss}"); + long ll = ((long)1024) * 1024 * 1024 * gb; + for (long ii = 0; ii < ll; ii++) + { + file.Write(bt); + // file.WriteByte(67); + } + DateTime dtTo = DateTime.Now; + TimeSpan ts = dtTo - dtFrom; + Console.WriteLine($"{sFileName}: {ts.TotalSeconds} sec"); + Console.ReadKey(); + } + } + + internal static void WriteLargeText(string sFileName, long rowCount) + { + byte[] bt = new byte[] { 67, 67, 67 }; + using (Stream file = File.Create(sFileName, 1024 * 64, FileOptions.DeleteOnClose)) + { + DateTime dtFrom = DateTime.Now; + Console.WriteLine($"{dtFrom:HHmmss}"); + using (StreamWriter writer = new StreamWriter(file, Encoding.UTF8)) + { + for (long ii = 0; ii < rowCount; ii++) + { + writer.WriteLine($"{dtFrom:HHmmss}"); + } + } + DateTime dtTo = DateTime.Now; + TimeSpan ts = dtTo - dtFrom; + Console.WriteLine($"{sFileName}: {ts.TotalSeconds} sec"); + Console.ReadKey(); + } + } } }