vb.net:
從策劃到設(shè)計(jì)制作,每一步都追求做到細(xì)膩,制作可持續(xù)發(fā)展的企業(yè)網(wǎng)站。為客戶提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)頁設(shè)計(jì)、主機(jī)域名、虛擬空間、網(wǎng)絡(luò)營銷、VI設(shè)計(jì)、 網(wǎng)站改版、漏洞修補(bǔ)等服務(wù)。為客戶提供更好的一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造優(yōu)易品牌,攜手廣大客戶,共同發(fā)展進(jìn)步。
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文件(文件寫入的編碼要與讀取的編碼一致)
解壓密碼:1299
假設(shè)路徑為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