Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleList information about the files in a directory in a ListView using Visual Basic 2005
DescriptionThis example shows how to list information about the files in a directory in a ListView using Visual Basic 2005. This example uses My.Computer.FileSystem.GetFiles to list the files.
Keywordsdirectory, list files, ListView, My, My.Computer, FileSystem, GetFiles, FileInfo, GetFileInfo
CategoriesControls
 
The program uses My.Computer.FileSystem.GetFiles to list the files in the directory. For each file name, it uses My.Computer.FileSystem.GetFileInfo to get a FileInfo object for the file. It uses that object to get the file's size, creation date, and last modification date.
 
Private Sub btnListFiles_Click(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) Handles _
    btnListFiles.Click
    lvwFileInfo.Items.Clear()

    For Each file_name As String In _
        My.Computer.FileSystem.GetFiles(txtDirectory.Text)
        Dim file_info As System.IO.FileInfo = _
            My.Computer.FileSystem.GetFileInfo(file_name)

        Dim new_item As ListViewItem = _
            lvwFileInfo.Items.Add(file_name)
        new_item.SubItems.Add(file_info.Length)
        new_item.SubItems.Add(file_info.CreationTime.ToString())
        new_item.SubItems.Add(file_info.LastWriteTime.ToString())
    Next file_name
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated