Guest User

Untitled

a guest
Jun 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Net.NetworkInformation;
  4.  
  5. namespace ConsoleApplication1
  6. {
  7. class Program
  8. {
  9.  
  10.  
  11. static void Main(string[] args)
  12. {
  13. double Incoming = 0;
  14. double Outgoing = 0;
  15. double TotalInterface;
  16. string SelectedInterface = "Local Area Connection";
  17.  
  18. NetworkInterface netInt = NetworkInterface.GetAllNetworkInterfaces().Single(n => n.Name.Equals(SelectedInterface));
  19.  
  20. for (; ; )
  21. {
  22. IPv4InterfaceStatistics ip4Stat = netInt.GetIPv4Statistics();
  23.  
  24. Incoming += (ip4Stat.BytesReceived - Incoming);
  25. Outgoing += (ip4Stat.BytesSent - Outgoing);
  26. TotalInterface = Incoming + Outgoing;
  27.  
  28. string Shutdown = ((TotalInterface > 40000D) ? "YES" : "NO");
  29.  
  30. string output = string.Format("Shutdown: {0} | {1} KB/s", Shutdown, TotalInterface.ToString());
  31. Console.WriteLine(output);
  32. }
  33. }
  34. }
  35. }
Add Comment
Please, Sign In to add comment