//public static ComputerInfo cif;
        static void Main(string[] args)
        {
            List <string> info = new List <string>();


            Console.WriteLine("磁盘总空间:{0}G", cipan.GetHardDiskSpace("C"));
            Console.WriteLine("剩余空间:{0}\n", cipan.GetHardDiskFreeSpace("C"));
            info.Add("磁盘总空间:" + cipan.GetHardDiskSpace("C") + "G");
            info.Add("剩余空间:" + cipan.GetHardDiskFreeSpace("C") + "G");
            info.Add("      \n");

            cpu = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            // cif = new ComputerInfo();
            MEMORY_INFO MemInfo;

            MemInfo = new MEMORY_INFO();



            while (true)
            {
                GlobalMemoryStatus(ref MemInfo);
                Console.WriteLine("内存利用率:" + MemInfo.dwMemoryLoad.ToString() + "%");
                info.Add("内存利用率:" + MemInfo.dwMemoryLoad.ToString() + "%");


                var percentage = cpu.NextValue();
                Console.WriteLine("CPU利用率:" + percentage + "%\n");
                info.Add("CPU利用率:" + percentage + "%");



                File.WriteAllLines(@"C:\Users\shanzm\Desktop\info.txt", info);


                System.Threading.Thread.Sleep(2000);
            }
        }
 public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);