|
|
@ -1,5 +1,7 @@ |
|
|
using ConsoleApp1.Animals; |
|
|
using ConsoleApp1.Animals; |
|
|
using ConsoleApp1.Cards; |
|
|
using ConsoleApp1.Cards; |
|
|
|
|
|
using System.Text; |
|
|
|
|
|
using System.Xml; |
|
|
|
|
|
|
|
|
namespace ConsoleApp1 |
|
|
namespace ConsoleApp1 |
|
|
{ |
|
|
{ |
|
|
@ -8,12 +10,158 @@ namespace ConsoleApp1 |
|
|
static void Main(string[] args) |
|
|
static void Main(string[] args) |
|
|
{ |
|
|
{ |
|
|
// h_PlayCards();
|
|
|
// h_PlayCards();
|
|
|
Animal animal = new Animal(); |
|
|
//Animal animal = new Animal();
|
|
|
Animal.MilkConsumerAreaInfo info = animal.GetAreaInfo(); |
|
|
//Animal.MilkConsumerAreaInfo info = animal.GetAreaInfo();
|
|
|
h_Afd(); |
|
|
//h_Afd();\
|
|
|
|
|
|
// h_InfoIO();
|
|
|
|
|
|
// File.Delete("123.csv");
|
|
|
|
|
|
// string sFn = "123.csv";
|
|
|
|
|
|
//h_WriteCsv(sFn);
|
|
|
|
|
|
//h_ReadCsv(sFn);
|
|
|
|
|
|
|
|
|
|
|
|
string sXmlFn = "123.xml"; |
|
|
|
|
|
h_WriteXml(sXmlFn); |
|
|
|
|
|
h_ReadXml(sXmlFn); |
|
|
Console.ReadKey(); |
|
|
Console.ReadKey(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void h_WriteXml(string sXmlFn) |
|
|
|
|
|
{ |
|
|
|
|
|
if (File.Exists(sXmlFn)) File.Delete(sXmlFn); |
|
|
|
|
|
if (File.Exists(sXmlFn)) return; |
|
|
|
|
|
Console.WriteLine(DateTime.Now); |
|
|
|
|
|
using (Stream ms = File.Create(sXmlFn)) |
|
|
|
|
|
{ |
|
|
|
|
|
using (XmlWriter sw = XmlWriter.Create(ms)) |
|
|
|
|
|
{ |
|
|
|
|
|
sw.WriteStartDocument(); |
|
|
|
|
|
sw.WriteStartElement("root"); |
|
|
|
|
|
sw.WriteAttributeString("versionMy", "1.0"); |
|
|
|
|
|
sw.WriteStartElement("items"); |
|
|
|
|
|
for (int ii = 0; ii < 2999999; ii++) |
|
|
|
|
|
{ |
|
|
|
|
|
sw.WriteStartElement("item"); |
|
|
|
|
|
sw.WriteAttributeString("attr1", $"{ii}"); |
|
|
|
|
|
sw.WriteString("content"); |
|
|
|
|
|
sw.WriteEndElement(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sw.WriteEndElement(); |
|
|
|
|
|
sw.WriteEndElement(); |
|
|
|
|
|
sw.WriteEndDocument(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileInfo fi = new FileInfo(sXmlFn); |
|
|
|
|
|
Console.WriteLine($"{fi.Length / 1024 / 1024} Mb / {DateTime.Now}"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void h_ReadXml(string sXmlFn) |
|
|
|
|
|
{ |
|
|
|
|
|
Console.WriteLine($"start {DateTime.Now}"); |
|
|
|
|
|
XmlDocument? x = new XmlDocument(); |
|
|
|
|
|
x.Load(sXmlFn); |
|
|
|
|
|
// x.ChildNodes[0].ChildNodes[0].Attributes[0].Value...
|
|
|
|
|
|
Console.WriteLine($"end {DateTime.Now}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void h_ReadCsv(string sFn) |
|
|
|
|
|
{ |
|
|
|
|
|
using (Stream ms = File.OpenRead(sFn)) |
|
|
|
|
|
{ |
|
|
|
|
|
using (StreamReader sr = new StreamReader(ms, System.Text.Encoding.UTF8)) |
|
|
|
|
|
{ |
|
|
|
|
|
sr.ReadLine(); |
|
|
|
|
|
int iCount = 0; |
|
|
|
|
|
string sLine = String.Empty; |
|
|
|
|
|
Console.WriteLine(sr.ReadLine()); |
|
|
|
|
|
while (!sr.EndOfStream) |
|
|
|
|
|
{ |
|
|
|
|
|
iCount++; |
|
|
|
|
|
sLine = sr.ReadLine(); |
|
|
|
|
|
} |
|
|
|
|
|
Console.WriteLine($"{iCount} // {sLine}"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void h_WriteCsv(string sFn) |
|
|
|
|
|
{ |
|
|
|
|
|
if (File.Exists(sFn)) return; |
|
|
|
|
|
using (Stream ms = File.Create(sFn)) |
|
|
|
|
|
{ |
|
|
|
|
|
using (StreamWriter sw = new StreamWriter(ms, System.Text.Encoding.UTF8)) |
|
|
|
|
|
{ |
|
|
|
|
|
sw.WriteLine($"num;date"); |
|
|
|
|
|
for (int ii = 0; ii < 99999999; ii++) |
|
|
|
|
|
{ |
|
|
|
|
|
sw.WriteLine($"{ii};{DateTime.Now:mm.ss}"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
FileInfo fi = new FileInfo(sFn); |
|
|
|
|
|
Console.WriteLine(fi.Length); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void h_InfoIO() |
|
|
|
|
|
{ |
|
|
|
|
|
var pp = typeof(Program).GetType().Assembly.Location; |
|
|
|
|
|
string sDirectory = Path.GetDirectoryName(pp); |
|
|
|
|
|
// Path.GetFileNameWithoutExtension()
|
|
|
|
|
|
// Path.ChangeExtension()
|
|
|
|
|
|
// DirectoryInfo di = new DirectoryInfo(sDirectory);
|
|
|
|
|
|
// di.EnumerateFiles();
|
|
|
|
|
|
// Directory.EnumerateFiles()
|
|
|
|
|
|
|
|
|
|
|
|
using (MemoryStream ms = new MemoryStream(new byte[40960])) |
|
|
|
|
|
{ |
|
|
|
|
|
ms.Seek(0, SeekOrigin.Begin); |
|
|
|
|
|
byte[] buffer = new byte[4096]; |
|
|
|
|
|
ms.Read(buffer, 1, 4096); |
|
|
|
|
|
int iB = ms.ReadByte(); |
|
|
|
|
|
using (StreamWriter sw = new StreamWriter(ms, System.Text.Encoding.UTF8)) |
|
|
|
|
|
{ |
|
|
|
|
|
sw.WriteLine("qwr"); |
|
|
|
|
|
} |
|
|
|
|
|
using (StreamReader sw = new StreamReader(ms, System.Text.Encoding.UTF8)) |
|
|
|
|
|
{ |
|
|
|
|
|
string sLine = sw.ReadLine(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
//Stream pFile = null;
|
|
|
|
|
|
//try
|
|
|
|
|
|
//{
|
|
|
|
|
|
// pFile = File.Create("sa");
|
|
|
|
|
|
// pFile.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
// byte[] buffer = new byte[4096];
|
|
|
|
|
|
// pFile.Read(buffer, 1, 4096);
|
|
|
|
|
|
// int iB = pFile.ReadByte();
|
|
|
|
|
|
//} finally
|
|
|
|
|
|
//{
|
|
|
|
|
|
// pFile?.Dispose();
|
|
|
|
|
|
//}
|
|
|
|
|
|
using (FileStream fs = File.Create("sa")) |
|
|
|
|
|
{ |
|
|
|
|
|
fs.Seek(0, SeekOrigin.Begin); |
|
|
|
|
|
byte[] buffer = new byte[4096]; |
|
|
|
|
|
fs.Read(buffer, 1, 4096); |
|
|
|
|
|
int iB = fs.ReadByte(); |
|
|
|
|
|
} |
|
|
|
|
|
byte[] bt = File.ReadAllBytes("fn"); |
|
|
|
|
|
string sText = File.ReadAllText("fn", Encoding.UTF8); |
|
|
|
|
|
string[] arLines = File.ReadAllLines("fn", Encoding.UTF8); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void h_XmlSax() |
|
|
|
|
|
{ |
|
|
|
|
|
string sContent = @""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private static void h_Afd() |
|
|
private static void h_Afd() |
|
|
{ |
|
|
{ |
|
|
int ii = 0; |
|
|
int ii = 0; |
|
|
@ -31,7 +179,7 @@ namespace ConsoleApp1 |
|
|
//h_CountOddAndEven(ll);
|
|
|
//h_CountOddAndEven(ll);
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static bool h_CountOddAndEven(List<int> ll, |
|
|
private static bool h_CountOddAndEven(List<int> ll, |
|
|
out int iEvenCount, out int iOddCount) |
|
|
out int iEvenCount, out int iOddCount) |
|
|
{ |
|
|
{ |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
|