public static void SerializedActiveProcesses(/*string file*/) { string file = @"../../Active Processes.txt"; List <string> list = PCStatus.ActiveProcesses(); FileStream s1 = new FileStream(file, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); using (s1) { formatter.Serialize(s1, list); } Console.WriteLine($"SerializedActiveProcesses() done at {Math.Round(sec, 1)} sec"); }
static void ActiveProcesses(/*string file*/) { int count = 0; string file = @"../../Active Processes.txt"; List <string> list = PCStatus.ActiveProcesses(); StreamWriter writer = new StreamWriter(new FileStream(file, FileMode.Create)); foreach (string elem in list) { writer.WriteLine(elem); count++; } writer.Write($"КОличество активных процессов: {count}"); writer.Close(); Console.WriteLine($"ActiveProcesses() done at {Math.Round(sec,1)} sec"); }
void SAP() { while (true) { try { string file = @"../../Active Processes.txt"; List <string> list = PCStatus.ActiveProcesses(); FileStream s1 = new FileStream(file, FileMode.Create); BinaryFormatter formatter = new BinaryFormatter(); using (s1) { formatter.Serialize(s1, list); } Thread.Sleep(1000); } catch { } } }