程序代码: | [ 复制代码到剪贴板 ] |
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AppPath As String = My.Application.Info.DirectoryPath
Dim Dir As New DirectoryInfo(AppPath)
Dim File As FileInfo
'文件夹下所有文件
For Each File In Dir.GetFiles("*.*")
Dim FileName As String = File.Name
Me.ListBox1.Items.Add(FileName)
Next
'文件夹下根文件夹
'Dim DirName As String
'For Each DirName In Directory.GetDirectories(AppPath)
' Me.ListBox1.Items.Add(DirName)
'Next
'文件夹下根文件夹
Dim Dir1 As DirectoryInfo
For Each Dir1 In Dir.GetDirectories
Me.ListBox1.Items.Add(Dir1.Name)
Next
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AppPath As String = My.Application.Info.DirectoryPath
Dim Dir As New DirectoryInfo(AppPath)
Dim File As FileInfo
'文件夹下所有文件
For Each File In Dir.GetFiles("*.*")
Dim FileName As String = File.Name
Me.ListBox1.Items.Add(FileName)
Next
'文件夹下根文件夹
'Dim DirName As String
'For Each DirName In Directory.GetDirectories(AppPath)
' Me.ListBox1.Items.Add(DirName)
'Next
'文件夹下根文件夹
Dim Dir1 As DirectoryInfo
For Each Dir1 In Dir.GetDirectories
Me.ListBox1.Items.Add(Dir1.Name)
Next
End Sub
End Class
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |