Im making a app that show's the key of all WLAN profiles on the computer.
'' GET PROFILES
Dim temp_direct As String = My.Computer.FileSystem.SpecialDirectories.Temp
Dim cmd As String = "Netsh WLAN show profiles > " & temp_direct & "\profiles.txt"
Shell("cmd.exe /c " + cmd, AppWinStyle.Hide, True)
'' SHOW PROFILES
Dim texto As String = File.ReadAllText(temp_direct & "\profiles.txt").Replace(" ", "")
Dim pattern As String = "AllUserProfile:(.*)"
Dim matches As MatchCollection = Regex.Matches(texto, pattern)
For Each m As Match In matches
For Each c As Capture In m.Captures
RichTextBox1.AppendText("SSID: " & m.Groups(1).Value)
'' SAVE PROFILE WITH CLEAR KEY
Dim cmd_info As String = "Netsh WLAN show profiles " & m.Groups(1).Value & " key=clear" & " > " & temp_direct & "\" & m.Groups(1).Value & ".txt"
Shell("cmd.exe /c " + cmd_info, AppWinStyle.Hide, True)
'' SHOW KEY ON RICHTEXTBOX
Dim ficheiro As String = m.Groups(1).Value & ".txt"
Dim pass_file As String = File.ReadAllText(Path.Combine(temp_direct, ficheiro)).Replace(" ", "")
Dim pattern_pass As String = "KeyContent:(.*)"
Dim match_key As Match = Regex.Match(pass_file, pattern_pass)
If match_key.Success Then
RichTextBox1.AppendText("Key: " & match_key.Groups(1).Value)
End If
Next
Next
I get an exception(Illegal characters in path) on:
Dim pass_file As String = File.ReadAllText(Path.Combine(temp_direct, ficheiro)).Replace(" ", "")
So i think the problem it's on the 'm.Groups(1).Value' for some reason it doesn't get recognize as a string? because if I use
Path.Combine(temp_direct, "NAME.txt")
Works that way, I tried to change the match to '.ToString', without the '.value' with the file type separated, etc, but it doesn't work. I also tried to search on forums but with no luck.