解压密码:1299
创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于网站设计、网站制作、敦化网络推广、成都小程序开发、敦化网络营销、敦化企业策划、敦化品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供敦化建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com
假设路径为C:\abc
代码:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Files As ObjectModel.ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles("C:\abc")
Dim FileSize As Long, FileName As String = Nothing
Dim oFileSize As Long
For Each File As String In Files
oFileSize = My.Computer.FileSystem.GetFileInfo(File).Length
If oFileSize FileSize Then
FileSize = oFileSize
FileName = File
End If
Next
Dim ListN As ListViewItem = New ListViewItem(My.Computer.FileSystem.GetName(FileName))
ListN.SubItems.Add(oFileSize " byte")
ListN.SubItems.Add(My.Computer.FileSystem.GetFileInfo(FileName).Extension " 文件")
ListN.SubItems.Add(FileName)
ListView1.Items.Add(ListN)
End Sub
End Class
详见源代码!!
'把下面的目录改成你要遍历的目录
Dim MyDir = "C:\Windows"
Dim MyInfo = MyDir + "目录下的所有文件包括:"
For Each MyFile In System.IO.Directory.GetFiles(MyDir)
MyInfo += Environment.NewLine + MyFile
Next
Me.RichTextBox1.Text =MyInfo
vb点虐 :
Dim path = System.IO.Directory.GetFiles("D:\Log\abc", "*.txt", SearchOption.AllDirectories):搜索该路径下的所有txt类型的目录及子目录
path.AddRange(path)
Dim _RecordInfo As String
Dim _Reader As StreamReader
_Reader = New StreamReader(file, System.Text.Encoding.Default):'以Default编码的形式读取file文件(文件写入的编码要与读取的编码一致)