static void SerializedInstalledSoft(/*string file*/) { string file = @"../../Installed Soft.txt"; FileStream s1 = new FileStream(file, FileMode.Create); ProgramSoft[] arr = PCStatus.InstalledSoft().ToArray <ProgramSoft>(); Array.Sort <ProgramSoft>(arr, (a, b) => a.Softname.CompareTo(b.Softname)); List <ProgramSoft> list = new List <ProgramSoft>(arr); BinaryFormatter formatter = new BinaryFormatter(); using (s1) { formatter.Serialize(s1, list); } Console.WriteLine($"SerializedInstalledSoft() done at {Math.Round(sec, 1)} sec"); }
static void InstalledSoft(/*string file*/) { string file = @"../../Installed Soft.txt"; int count = 0; StreamWriter writer = new StreamWriter(new FileStream(file, FileMode.Create)); ProgramSoft[] arr = PCStatus.InstalledSoft().ToArray <ProgramSoft>(); Array.Sort <ProgramSoft>(arr, (a, b) => a.Softname.CompareTo(b.Softname)); foreach (var elem in arr) { writer.WriteLine(elem.GetFields()); count++; } writer.Write($"Количество установленного ПО: {count}"); writer.Close(); Console.WriteLine($"InstalledSoft() done at {Math.Round(sec, 1)} sec"); }