I got to spend the other day with a local customer that was making the shift to .NET. They were in the process of doing some prototyping their current application. They actually had a small VB application that was responsible for searching a local file share and returning a list of files that matched the search and their sizes. I put together the following snippet that I thought was interesting.
Imports System.IO
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim File
Dim Files() As fileinfo
Dim DirInfo As New DirectoryInfo("c:\")
Files = DirInfo.GetFiles("*.txt")
' display names
For Each File In Files
MsgBox("Name: " & File.Name)
MsgBox("Size: " & File.length.ToString)
Next
End Sub
**Note**
The GetFiles operator accepts either the “?” or “*” search wildcards.
11:10:16 PM
|