Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionImports 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