Skip to content

Commit

Permalink
Handlng rare null case
Browse files Browse the repository at this point in the history
Handlng rare null case with managed Wifi Networks. Also added "progress
bar"
  • Loading branch information
shanselman committed Jan 28, 2017
1 parent 480d4d2 commit b423fef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions WifiProfiles/NetShWlanWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public static List<WifiProfile> GetWifiProfiles()
{
profiles.Add(new WifiProfile() {
Name = x.Descendants(ns + "name").First().Value,
ConnectionMode = x.Descendants(ns + "connectionMode").First().Value,
Authentication = x.Descendants(ns + "authentication").First().Value
ConnectionMode = x.Descendants(ns + "connectionMode").FirstOrDefault()?.Value,
Authentication = x.Descendants(ns + "authentication").FirstOrDefault()?.Value
});
}
}
Expand Down Expand Up @@ -62,8 +62,9 @@ private static void ExportAllWifiProfiles()
foreach (var match in listOfProfiles)
{
ExecuteNetSh(String.Format("wlan export profile \"{0}\" folder=\"{1}\"", match.ToString(), Environment.CurrentDirectory));

Console.Write(".");
}
Console.WriteLine();
}

public static void DeleteExportedWifiProfiles()
Expand Down
2 changes: 1 addition & 1 deletion WifiProfiles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void List(bool autoDelete)
foreach (var a in profiles)
{
var warning = NetShWrapper.IsOpenAndAutoWifiProfile(a) ? Resources.stringResources.WarningAutoConnect : String.Empty;
Console.WriteLine("{0,-20} {1,10} {2,10} {3,30} ", a.Name, a.ConnectionMode, a.Authentication, warning);
Console.WriteLine("{0,-30} {1,10} {2,10} {3,30} ", a.Name, a.ConnectionMode, a.Authentication, warning);
if (!String.IsNullOrWhiteSpace(warning)) badWifiNetworkFound = true;
}

Expand Down

0 comments on commit b423fef

Please sign in to comment.