Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Using ListDirectory to display only directories not files

    For Each fileInfo In directory.Files
        If fileInfo.IsDirectory And (Not fileInfo.IsThisDirectory) Then
            .Items.Add(fileInfo.Name)
        End If
    Next
davefrag

Using ListDirectory to display only directories not files

I'm using vb.net code to open an SFTP session and list only directories, not files within directories. I have not yet been successful in creating a listing of only directories. I included the vb.net code below which should be putting only the names of directories in a listview container although I can't seem to get it to work. Any help is appreciated.

Dim directory
Dim fileInfo
directory = mySession.ListDirectory(ManageHosts.tbx_DestDirectory.Text)
Lbx_DestDirectory.Items.Clear()
With Lbx_DestDirectory
    For Each fileInfo In directory.Files
        If fileInfo.Name <> "." Or fileInfo.Name = "*." Then
            .Items.Add(fileInfo.Name)
        End If
    Next
End With