VB.Net Version
Imports
System.IO
Public
Class Form1
Inherits
System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim
dirInfo As DirectoryInfo = New DirectoryInfo("C:\")
'now get all files contained in the directory.
Dim aFiles() As FileInfo =
dirInfo.GetFiles("*.*")
Dim aDirs() As DirectoryInfo =
dirInfo.GetDirectories
DataGrid1.DataSource = aFiles
DataGrid2.DataSource = aDirs
ListBox1.DataSource = aFiles
MsgBox(aFiles(0).FullName)
End Sub
ASP.Net Version
Imports
System.IO
Imports
System.IO.FileInfo
Public
Class WebForm1
Inherits
System.Web.UI.Page
Protected WithEvents txtFI As
System.Web.UI.WebControls.TextBox
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Private Sub Page_Load(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim
dirInfo As DirectoryInfo = New DirectoryInfo("C:\")
Dim aDirs() As DirectoryInfo =
dirInfo.GetDirectories()
Dim afiles() As
System.IO.FileInfo = dirInfo.GetFiles("m*.*")
Dim
vFile As New System.IO.FileInfo(afiles(0).FullName.ToString)
DataGrid1.DataSource = aDirs
DataGrid1.DataBind()
txtFI.Text = vFile.FullName.ToString
End Sub
End Class