143 lines
5.6 KiB
VB.net
143 lines
5.6 KiB
VB.net
Imports System.IO
|
|
Imports System.Net
|
|
Imports System.Reflection.Emit
|
|
Imports System.Threading
|
|
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
|
|
|
|
Public Class Form21
|
|
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
|
|
Button1.Text = "créer: " & TextBox1.Text
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
If TextBox1.Text = "" Then
|
|
MsgBox("merci d'entrer un nom", MsgBoxStyle.Exclamation)
|
|
Else
|
|
Try
|
|
Directory.CreateDirectory(dostemps & TextBox1.Text)
|
|
Directory.Delete(dostemps & TextBox1.Text)
|
|
vérifiliste()
|
|
Catch ex As Exception
|
|
MsgBox("le nom comporte de caratère interdit", MsgBoxStyle.Exclamation)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
Sub vérifiliste()
|
|
Try
|
|
Dim fwr As FtpWebRequest
|
|
fwr = FtpWebRequest.Create(ipserver & "utilisateur/" & nomutilisateur & "/liste/")
|
|
fwr.Credentials = New NetworkCredential("extremedownloaders", passftp)
|
|
fwr.Method = WebRequestMethods.Ftp.ListDirectory
|
|
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
|
|
|
|
Dim str As String = sr.ReadLine()
|
|
While Not str Is Nothing
|
|
|
|
|
|
Directory.CreateDirectory(dostemps & str)
|
|
|
|
str = sr.ReadLine()
|
|
End While
|
|
sr.Close()
|
|
|
|
If Directory.Exists(dostemps & TextBox1.Text) = True Then
|
|
For Each fichier As String In IO.Directory.GetDirectories(dostemps)
|
|
Dim info As New IO.FileInfo(fichier)
|
|
Directory.Delete(dostemps & info.Name)
|
|
Next
|
|
MsgBox("la liste: " & TextBox1.Text & " exsite dêjâ", MsgBoxStyle.Exclamation)
|
|
Else
|
|
For Each fichier As String In IO.Directory.GetDirectories(dostemps)
|
|
Dim info As New IO.FileInfo(fichier)
|
|
Directory.Delete(dostemps & info.Name)
|
|
Next
|
|
creerliste()
|
|
End If
|
|
Catch ex As Exception
|
|
Timer1.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
|
Timer1.Stop()
|
|
Try
|
|
Dim fwr As FtpWebRequest
|
|
fwr = FtpWebRequest.Create(ipserver & "utilisateur/" & nomutilisateur & "/liste/")
|
|
fwr.Credentials = New NetworkCredential("extremedownloaders", passftp)
|
|
fwr.Method = WebRequestMethods.Ftp.ListDirectory
|
|
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
|
|
|
|
Dim str As String = sr.ReadLine()
|
|
While Not str Is Nothing
|
|
|
|
|
|
Directory.CreateDirectory(dostemps & str)
|
|
|
|
str = sr.ReadLine()
|
|
End While
|
|
sr.Close()
|
|
|
|
If Directory.Exists(dostemps & TextBox1.Text) = True Then
|
|
For Each fichier As String In IO.Directory.GetDirectories(dostemps)
|
|
Dim info As New IO.FileInfo(fichier)
|
|
Directory.Delete(dostemps & info.Name)
|
|
Next
|
|
MsgBox("la liste: " & TextBox1.Text & " exsite dêjâ", MsgBoxStyle.Exclamation)
|
|
Else
|
|
For Each fichier As String In IO.Directory.GetDirectories(dostemps)
|
|
Dim info As New IO.FileInfo(fichier)
|
|
Directory.Delete(dostemps & info.Name)
|
|
Next
|
|
creerliste()
|
|
End If
|
|
Catch ex As Exception
|
|
Timer1.Start()
|
|
End Try
|
|
End Sub
|
|
Sub creerliste()
|
|
Try
|
|
Dim MaRequete As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(ipserver & "utilisateur/" & nomutilisateur & "/liste/" & TextBox1.Text), System.Net.FtpWebRequest)
|
|
Dim ftpStream As Stream = Nothing
|
|
|
|
MaRequete.Credentials = New System.Net.NetworkCredential("extremedownloaders", passftp)
|
|
MaRequete.Method = System.Net.WebRequestMethods.Ftp.MakeDirectory
|
|
|
|
Dim response As FtpWebResponse = CType(MaRequete.GetResponse, FtpWebResponse)
|
|
ftpStream = response.GetResponseStream
|
|
ftpStream.Close()
|
|
response.Close()
|
|
fini()
|
|
Catch ex As Exception
|
|
Timer2.Start()
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
|
|
Timer2.Stop()
|
|
Try
|
|
Dim MaRequete As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(ipserver & "utilisateur/" & nomutilisateur & "/liste/" & TextBox1.Text), System.Net.FtpWebRequest)
|
|
Dim ftpStream As Stream = Nothing
|
|
|
|
MaRequete.Credentials = New System.Net.NetworkCredential("extremedownloaders", passftp)
|
|
MaRequete.Method = System.Net.WebRequestMethods.Ftp.MakeDirectory
|
|
|
|
Dim response As FtpWebResponse = CType(MaRequete.GetResponse, FtpWebResponse)
|
|
ftpStream = response.GetResponseStream
|
|
ftpStream.Close()
|
|
response.Close()
|
|
fini()
|
|
Catch ex As Exception
|
|
Timer2.Start()
|
|
End Try
|
|
End Sub
|
|
Sub fini()
|
|
Form2.Button22.Show()
|
|
Form2.ComboBox4.Show()
|
|
Form2.TextBox15.Show()
|
|
Form2.PictureBox9.Show()
|
|
Form2.ComboBox4.Items.Add(TextBox1.Text)
|
|
Form2.ComboBox4.SelectedItem = TextBox1.Text
|
|
MsgBox("la liste: " & TextBox1.Text & " a bien êtê créer", MsgBoxStyle.Information)
|
|
Close()
|
|
End Sub
|
|
End Class |