Пример #1
0
        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");
        }
Пример #2
0
        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");
        }
Пример #3
0
 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 { }
     }
 }