Salut,je vous explique mon problème:
Je voudrais crée un programme qui cherche des elements dans un dossier
spécifier et qui copie ce que l'utilisataeur a cocher dans un dossier sur
le bureau.
Je dispose donc:
*D'une checklistbox (pour selectionner les items rechercher.)
*D'une combo-box(pour dire de rechercher a telle endroit)
* De 1 bouton(pour copier les items selectionner dans le bureau)
*+ 1 bouton(pour effacer ce qu'il y a dans la checklistbox)
d'une textbox (pour la recherche des dossier)
Donc voici le code pour rechercher
Pourquoi est-ce que j'ai mis points?est bien parce que si je mets .NK2 il ne trouve pas,si il y a un problème pour régler sa merci de m'en informer.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedItem = "C:\Documents and Settings\" & Form1.TextBox1.Text & "\Application Data\Microsoft\Outlook" Then For Each Fichier As String In My.Computer.FileSystem.GetFiles("C:\Documents and Settings\" & Form1.TextBox1.Text & "\Application Data\Microsoft\Outlook", FileIO.SearchOption.SearchAllSubDirectories) If Path.GetFileName(Fichier).ToLower.Contains(".") Then CheckedListBox1.Items.Add(Fichier) End If Next End If End Sub
Voici le code pour la combobox:
Et VOICI LE CODE pour copier le fichier(qui ne marche pas)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("C:\Documents and Settings\" & Form1.TextBox1.Text & "\Application Data\Microsoft\Outlook") End Sub
ET sa me mets comme erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click CheckedListBox1.SelectedItems.CopyTo("C:\Documents and Settings\" & Form1.TextBox1.Text & "\Desktop\Nouveau dossier") End Sub End Class
ET VOICI LE CODE EN ENTIERErreur 1 Argument non spécifié pour le paramètre 'index' de 'Public Sub CopyTo(destination As System.Array, index As Integer)'
Erreur 2 Une valeur de type 'String' ne peut pas être convertie en 'System.Array'.
J'aimerais que l'on me disent comment faire pour copier les element cocher qui ont été rechercher dans un dossier.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 Imports System.IO Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("C:\Documents and Settings\" & Form1.TextBox1.Text & "\Application Data\Microsoft\Outlook") End Sub Private Sub ListBox1_selectedIndexChanged(ByVal send As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click CheckedListBox1.Items.Clear() End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedItem = "C:\Documents and Settings\" & Form1.TextBox1.Text & "\Application Data\Microsoft\Outlook" Then For Each Fichier As String In My.Computer.FileSystem.GetFiles("C:\Documents and Settings\" & Form1.TextBox1.Text & "\Application Data\Microsoft\Outlook", FileIO.SearchOption.SearchAllSubDirectories) If Path.GetFileName(Fichier).ToLower.Contains(".") Then CheckedListBox1.Items.Add(Fichier) End If Next End If End Sub Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click CheckedListBox1.SelectedItems.CopyTo("C:\Documents and Settings\" & Form1.TextBox1.Text & "\Desktop\Nouveau dossier") End Sub End Class
Ne vous occuper pas de & Form1.TextBox1.Text & c'est parce qu'il y a une autre fenetre pour indiquer cette element.
Partager