Arborescence des disques locaux

benjamin3322 Messages postés 11 Date d'inscription mercredi 31 décembre 2008 Statut Membre Dernière intervention 17 décembre 2011 - 5 déc. 2010 à 00:07
benjamin3322 Messages postés 11 Date d'inscription mercredi 31 décembre 2008 Statut Membre Dernière intervention 17 décembre 2011 - 24 juin 2011 à 19:03
Bonjour a tous,

C'est mon premier post sur votre forum, car jusque là j'ai toujours tout trouvé ...

je débute et comme premier programme je fait une sorte de client FTP super simplifier ...

le programme fonctionne bien, il se connecte au nom d'hôte avec un utilisateur et un mot de passe et il récupère la liste des dossiers et fichiers qui sont afficher dans une listview ...

mais je n'arrive pas a afficher l'arborescence des disques locaux dans une autre listview ...

je parle d'une liste view du style de :

...
Bureau
Mes Documents
Ma Musique
Mes Images
C:/
D:/
E:/
G:/
S:/
F:/

j'y arrive +/- avec un treeview j'affiche les dossiers/Fichiers du disque c:/ , les dossiers/Fichiers de Mes Documents et le reste est vide ..??
et les disques amovibles ne sont pas afficher ...

j'ai télécharger 2 source de client ftp et elle ne mon pas aider ... car c'est variable sur variable

pour des raisons esthétique j'ai choisi d'afficher l'arborescence dans une listview mais si c'est trop complexe ... je corrigerait mes fautes du treeview

Merci de votre aide

p.s : j'utilise visual basic express 2010

7 réponses

benjamin3322 Messages postés 11 Date d'inscription mercredi 31 décembre 2008 Statut Membre Dernière intervention 17 décembre 2011
5 déc. 2010 à 16:15
Salut, j'ai réussi maintenant j'ai tout les lecteurs dans un listview mais il n'y a pas leur nom juste le lettre,mais ca fonctionne c'est deja ca ....

Merci quand même
0
cs_lamono Messages postés 3 Date d'inscription mercredi 22 juin 2011 Statut Membre Dernière intervention 24 juin 2011
22 juin 2011 à 15:51
sa serait cool si tu pourrait me dire comment tu as fait pour mettre une arborescence dans une listview !!
0
benjamin3322 Messages postés 11 Date d'inscription mercredi 31 décembre 2008 Statut Membre Dernière intervention 17 décembre 2011
22 juin 2011 à 20:49
Salut lamono je cherche comment j'ai fait et je poste ça illico car entre temps j'ai changer de pc ... perdu des données etc.

Mais je dois encore avoire mon petit programmes ;-)
0
cs_lamono Messages postés 3 Date d'inscription mercredi 22 juin 2011 Statut Membre Dernière intervention 24 juin 2011
23 juin 2011 à 09:06
ok ba j'attend de tes nouvelles !! au plus vite j'espère :)
Mais je te remercie de chercher
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
benjamin3322 Messages postés 11 Date d'inscription mercredi 31 décembre 2008 Statut Membre Dernière intervention 17 décembre 2011
23 juin 2011 à 16:27
Salut, voici le Code que j'ai utiliser pour afficher L’arborescence des Disques locaux
----------------------------------------------------
Imports System.Text
Imports System.IO
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ShowLocalFileAndFolder()
    End Sub



    'Show the list of file and folder of Local computer
    Sub ShowLocalFileAndFolder()
        'Clear the listview
        If LVLocal.Items.Count > 0 Then
            LVLocal.Items.Clear()
        End If

        'If we are showing the folders
        If SBarFTP.Panels(0).Text <> "Logical drives" Then
            'Add the back directory

            LVLocal.Items.Add("...", 0).SubItems.Add(DateTime.Now.Day.ToString + "." + DateTime.Now.Month.ToString + "." + DateTime.Now.Year.ToString)


            'Recover the list of the directory
            'fait la liste des dossiers
            Dim dirs() As String = Directory.GetDirectories(SBarFTP.Panels(0).Text)
            'If there are directories, show there
            If dirs.Length > 0 Then
                For i As Integer = 0 To dirs.Length - 1
                    Dim dateFormatee As String = Directory.GetLastAccessTime(dirs(i)).Day.ToString + "." + Directory.GetLastAccessTime(dirs(i)).Month.ToString + "." + Directory.GetLastAccessTime(dirs(i)).Year.ToString
                    LVLocal.Items.Add(dirs(i).Substring(dirs(i).LastIndexOf("") + 1, dirs(i).Length - 1 - dirs(i).LastIndexOf("")), 0).SubItems.Add(dateFormatee)
                Next
            End If

            'Recover the list of the files
            'fait la liste des fichiers
            Dim files() As String = Directory.GetFiles(SBarFTP.Panels(0).Text)
            'If there are files, show there
            If files.Length > 0 Then
                For i As Integer = 0 To files.Length - 1
                    Dim dateFormatee As String = File.GetLastAccessTime(files(i)).Day.ToString + "." + File.GetLastAccessTime(files(i)).Month.ToString + "." + File.GetLastAccessTime(files(i)).Year.ToString
                    LVLocal.Items.Add(files(i).Substring(files(i).LastIndexOf("") + 1, files(i).Length - files(i).LastIndexOf("") - 1), 1).SubItems.Add(dateFormatee)
                Next
            End If
        Else
            'Recover the list of drives
            ' Fait la liste des "Disques"
            Dim drives() As String = Directory.GetLogicalDrives
            'If there are files, show there
            If drives.Length > 0 Then
                For i As Integer = 0 To drives.Length - 1
                    LVLocal.Items.Add(drives(i), 2)
                Next
            End If
        End If
    End Sub



    'LVLocal.DoubleClick
    'Quand tu clique 2 fois sur un ithem ... pour qu'il développe
    Private Sub LVLocal_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LVLocal.DoubleClick
        'if there is a selected item
        If LVLocal.SelectedItems.Count > 0 Then
            'If it's a folder or a logical drive
            If LVLocal.SelectedItems(0).ImageIndex 0 Or LVLocal.SelectedItems(0).ImageIndex 2 Then
                'If we're in a logical drive (for exemple C:/) and wan't to come back
                If LVLocal.SelectedItems(0).Text "..." And SBarFTP.Panels(0).Text Directory.GetDirectoryRoot(SBarFTP.Panels(0).Text) Then
                    SBarFTP.Panels(0).Text = "Logical drives"
                    ShowLocalFileAndFolder()
                    'If we're in a folder and wan't to comme back
                ElseIf LVLocal.SelectedItems(0).Text = "..." Then
                    SBarFTP.Panels(0).Text = Directory.GetParent(SBarFTP.Panels(0).Text).ToString
                    ShowLocalFileAndFolder()
                    'If we're in no logical drive and choose one of them
                ElseIf SBarFTP.Panels(0).Text = "Logical drives" Then
                    SBarFTP.Panels(0).Text = LVLocal.SelectedItems(0).Text
                    ShowLocalFileAndFolder()
                Else
                    'If we're in a logical drives and choose one folder
                    If SBarFTP.Panels(0).Text <> Directory.GetDirectoryRoot(SBarFTP.Panels(0).Text) Then
                        SBarFTP.Panels(0).Text += "" + LVLocal.SelectedItems(0).Text
                        ShowLocalFileAndFolder()
                    Else
                        SBarFTP.Panels(0).Text += LVLocal.SelectedItems(0).Text
                        ShowLocalFileAndFolder()
                    End If
                End If
            End If
        End If
    End Sub



    'LVLocal.SelectedIndexChanged
    'Show hide the button in the toolbar to download a file
    Private Sub LVLocal_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LVLocal.SelectedIndexChanged

        'If there is a selected item
        If LVLocal.SelectedItems.Count > 0 Then
            'If this is a file
            If LVLocal.SelectedItems(0).ImageIndex = 1 Then
                'TBBtnDownload.Enabled = True
            Else
                'TBBtnDownload.Enabled = False
            End If
        Else
            ' TBBtnDownload.Enabled = False
        End If
    End Sub

End Class

----------------------------------
Pour les 30 erreurs :
LVLocal: Créer une listview du nom de :LVLocal
SBarFTP: Créer une bar de status du nom de :SBarFTP

Et voila en espérant t'avoir aider ;-)
0
cs_lamono Messages postés 3 Date d'inscription mercredi 22 juin 2011 Statut Membre Dernière intervention 24 juin 2011
24 juin 2011 à 15:02
ok je te remercie mais je ne vois pas a quoi correspond ta "bar de status" dans la boite à outil?
0
benjamin3322 Messages postés 11 Date d'inscription mercredi 31 décembre 2008 Statut Membre Dernière intervention 17 décembre 2011
24 juin 2011 à 19:03
Salut, effectivement ... la "statutsbar" n'est pas dans les outils

a mettre dans le disigner de la form :
après "Private Sub InitializeComponent()"
Me.SBarFTP = New System.Windows.Forms.StatusBar()
Me.SBarPanelFtp = New System.Windows.Forms.StatusBarPanel()
Me.SBarPanelHost = New System.Windows.Forms.StatusBarPanel()
CType(Me.SBarPanelFtp, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SBarPanelHost, System.ComponentModel.ISupportInitialize).BeginInit()
'
'SBarFTP
'
Me.SBarFTP.Location = New System.Drawing.Point(0, 506)
Me.SBarFTP.Name = "SBarFTP"
Me.SBarFTP.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.SBarPanelFtp, Me.SBarPanelHost})
Me.SBarFTP.ShowPanels = True
Me.SBarFTP.Size = New System.Drawing.Size(1116, 24)
Me.SBarFTP.TabIndex = 26
Me.SBarFTP.Text = "StatusBar1"
'
'SBarPanelFtp
'
Me.SBarPanelFtp.Name = "SBarPanelFtp"
Me.SBarPanelFtp.Text = "Logical drives"
'
'SBarPanelHost
'
Me.SBarPanelHost.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.SBarPanelHost.Name = "SBarPanelHost"
Me.SBarPanelHost.Text = "/"
Me.SBarPanelHost.Width = 999
'
'Form1
'
Me.Controls.Add(Me.SBarFTP)
CType(Me.SBarPanelFtp, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SBarPanelHost, System.ComponentModel.ISupportInitialize).EndInit()

après "End Sub" mais avant le "end class"
-------
Friend WithEvents SBarFTP As System.Windows.Forms.StatusBar
Friend WithEvents SBarPanelFtp As System.Windows.Forms.StatusBarPanel
Friend WithEvents SBarPanelHost As System.Windows.Forms.StatusBarPanel
-------

et voila tu continue et ignore l'avertissement et la barre est apparue
0
Rejoignez-nous