Browse Source

file streams

master
2 4 weeks ago
parent
commit
a8227888b6
  1. 6
      ConsoleCore/Program.cs
  2. 41
      ConsoleCore/RobotFiler.cs

6
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<CleanSpace> arWeekDirty =
app.GetDirtyCleanSpace(7);
*/
RobotFiler.WriteLargeStream(Path.Combine(".", "tmp.txt"), 1);
RobotFiler.WriteLargeText(Path.Combine(".", "tmp.txt"), 1);
}

41
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();
}
}
}
}

Loading…
Cancel
Save