TextBox10.Clear()
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox17.Text = FolderBrowserDialog1.SelectedPath + "\sauvftp"
If Directory.Exists(TextBox17.Text) = True Then
Select Case MsgBox("Dossier existant remplacer ?", MsgBoxStyle.YesNo, "Erreur")
Case MsgBoxResult.Yes
Try
My.Computer.FileSystem.DeleteDirectory(TextBox17.Text, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
Catch ex As Exception
End Try
Case MsgBoxResult.No
Exit Sub
End Select
End If
''''
Try
My.Computer.FileSystem.CreateDirectory(TextBox17.Text)
Catch ex As Exception
End Try
''''
Try
Dim arr() As String
Dim request As FtpWebRequest = WebRequest.Create(TextBox3.Text)
request.Credentials = New NetworkCredential(TextBox4.Text, TextBox5.Text)
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
Dim response As FtpWebResponse = request.GetResponse()
Dim responseStream As Stream = response.GetResponseStream()
Dim reader As StreamReader = New StreamReader(responseStream)
Dim lol As String
Do
lol = reader.ReadLine
If Len(lol) < 1 Then Exit Do
arr = Split(lol, vbNewLine)
For i = 0 To UBound(arr)
If Len(arr(i)) > 0 Then
'ListBox3.Items.Add(arr(i))
TextBox10.AppendText(arr(i) & vbCrLf)
End If
Next
Loop
reader.Close()
response.Close()
Catch ex As Exception
MsgBox("connection impossible")
End Try
''''
Try
My.Computer.FileSystem.DeleteFile(TextBox17.Text + "/lstftp.txt")
Catch ex As Exception
End Try
Dim sw As StreamWriter
Dim path = TextBox17.Text + "/lstftp.txt"
If File.Exists(Path) = False Then
' Create a file to write to.
sw = File.CreateText(Path)
sw.WriteLine(TextBox10.Text)
sw.Close()
End If
Try
Dim nbr_ligne As Integer = 0
Dim ligne As String
Dim sr As New StreamReader(TextBox17.Text + "/lstftp.txt")
While sr.Peek <> -1
nbr_ligne += 1
ligne = sr.ReadLine()
TextBox19.Text = ligne
Do
If ligne = "" Then Exit Do
If TextBox19.Text Like "*:*" Then
Try
TextBox19.Text = Strings.Right(TextBox19.Text, Len(TextBox19.Text) - 1)
Catch ex As Exception
End Try
End If
If TextBox19.Text Like "*:*" = False Then
Try
TextBox19.Text = Strings.Right(TextBox19.Text, Len(TextBox19.Text) - 3)
If TextBox19.Text Like "*.*" = False Then
TextBox19.AppendText("/")
End If
Catch ex As Exception
End Try
TextBox18.AppendText(TextBox19.Text & vbCrLf)
Exit Do
End If
Loop
' MsgBox("la ligne" & nbr_ligne & ": " & ligne)
End While
' MsgBox("Nombre de ligne=" & nbr_ligne)
sr.Close()
Catch ex As Exception
End Try
''''
Try
My.Computer.FileSystem.DeleteFile(TextBox17.Text + "/lstftp.txt")
Catch ex As Exception
End Try
Dim sw1 As StreamWriter
Dim path1 = TextBox17.Text + "/lstftp.txt"
If File.Exists(path1) = False Then
' Create a file to write to.
sw1 = File.CreateText(path1)
sw1.WriteLine(TextBox18.Text)
sw1.Close()
End If
''''
TextBox10.Clear()
TextBox18.Clear()
TextBox19.Clear()
Dim SR1 As New StreamReader(TextBox17.Text + "/lstftp.txt")
TextBox10.Clear()
TextBox10.Text = SR1.ReadToEnd
SR1.Close()
''''
Dim nbr_ligne1 As Integer = 0
Dim ligne1 As String
Dim sr11 As New StreamReader(TextBox17.Text + "/lstftp.txt")
While sr11.Peek <> -1
nbr_ligne1 += 1
ligne1 = sr11.ReadLine()
TextBox19.Text = ligne1
TextBox20.Text = Len(TextBox19.Text)
Dim a = TextBox20.Text
TextBox21.Text = Strings.Right(TextBox19.Text, Len(TextBox19.Text) - (a - 1))
If TextBox21.Text Like "*/*" = False Then
Dim user = TextBox4.Text
Dim pass = TextBox5.Text
Dim fichlocal9 = TextBox17.Text + "" + TextBox19.Text
Dim fichftp9 = TextBox3.Text + TextBox19.Text
Try
My.Computer.Network.DownloadFile(fichftp9, fichlocal9, user, pass)
Catch ex As Exception
End Try
End If
If TextBox21.Text Like "*/*" Then
Try
My.Computer.FileSystem.CreateDirectory(TextBox17.Text + "" + TextBox19.Text)
Catch ex As Exception
End Try
TextBox18.AppendText(TextBox19.Text & vbCrLf)
End If
'MsgBox("la ligne" & nbr_ligne1 & ": " & ligne1)
End While
'MsgBox("Nombre de ligne=" & nbr_ligne1)
sr11.Close()
'''''''''
TextBox10.Text = TextBox18.Text
TextBox18.Clear()
TextBox19.Clear()
TextBox20.Clear()
TextBox21.Clear()
Try
My.Computer.FileSystem.DeleteFile(TextBox17.Text + "/lstftp.txt")
Catch ex As Exception
End Try
Dim sw2 As StreamWriter
Dim path2 = TextBox17.Text + "/lstftp.txt"
If File.Exists(path2) = False Then
' Create a file to write to.
sw2 = File.CreateText(path2)
sw2.WriteLine(TextBox10.Text)
sw2.Close()
End If
''''