P
Pascal
Hi everybody
I try to create folders from a list stored in a listbox. It works a
"little"but, i would like to create these folders only if they don't exist.
here is the code i use :
Private Sub btnCreateFolders_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCreateFolders.Click
Try
Dim i As Integer
For i = 0 To lstbEleves.Items.Count - 1
' Open the path
Dim D As DirectoryInfo
D = New DirectoryInfo(ParentFolder)
Dim SD As DirectoryInfo
SD = New DirectoryInfo(lstbEleves.Items.Item(i))
' Vérify existence of directory
If D.Exists Then
If SD.Exists Then
'Do nothing because the subdirectory already exists in the parent folder
Else
'Create the sub-directory with the name from the listbox
D.CreateSubdirectory(lstbEleves.Items.Item(i).ToString)
End If
End If
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
End Try
End Sub
I don't why it doesn't work.
If i don't put any if the folders are created..... but there no test!
can you help
thanks
pascal
http://www.scalpa.info
I try to create folders from a list stored in a listbox. It works a
"little"but, i would like to create these folders only if they don't exist.
here is the code i use :
Private Sub btnCreateFolders_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCreateFolders.Click
Try
Dim i As Integer
For i = 0 To lstbEleves.Items.Count - 1
' Open the path
Dim D As DirectoryInfo
D = New DirectoryInfo(ParentFolder)
Dim SD As DirectoryInfo
SD = New DirectoryInfo(lstbEleves.Items.Item(i))
' Vérify existence of directory
If D.Exists Then
If SD.Exists Then
'Do nothing because the subdirectory already exists in the parent folder
Else
'Create the sub-directory with the name from the listbox
D.CreateSubdirectory(lstbEleves.Items.Item(i).ToString)
End If
End If
Next
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
End Try
End Sub
I don't why it doesn't work.
If i don't put any if the folders are created..... but there no test!
can you help
thanks
pascal
http://www.scalpa.info