Esempio n. 1
0
 private static long?GetSpeed(string name)
 {
     try
     {
         string path = Path.Combine(NetworkFiles.SysClassNetFolder, name, NetworkFiles.SpeedFileName);
         return(StringParsingHelpers.ParseRawLongFile(path));
     }
     catch (IOException) // Some interfaces may give an "Invalid argument" error when opening this file.
     {
         return(null);
     }
 }
 private static long?GetSpeed(string name)
 {
     try
     {
         string path = Path.Combine(NetworkFiles.SysClassNetFolder, name, NetworkFiles.SpeedFileName);
         return(StringParsingHelpers.ParseRawLongFile(path));
     }
     catch (Exception) // Ignore any problems accessing or parsing the file.
     {
         return(null);
     }
 }
Esempio n. 3
0
 private static long?GetSpeed(string name)
 {
     try
     {
         string path = Path.Combine(NetworkFiles.SysClassNetFolder, name, NetworkFiles.SpeedFileName);
         long   megabitsPerSecond = StringParsingHelpers.ParseRawLongFile(path);
         return(megabitsPerSecond == -1
             ? megabitsPerSecond
             : megabitsPerSecond * 1_000_000); // Value must be returned in bits per second, not megabits.
     }
     catch (Exception)                         // Ignore any problems accessing or parsing the file.
     {
         return(null);
     }
 }