當前位置:成語大全網 - 書法字典 - VB.NET如何遍歷整個文件夾並找到壹個文件?

VB.NET如何遍歷整個文件夾並找到壹個文件?

解壓密碼:1299

假設路徑是C:\abc。

代碼:

公共類Form1私有子form 1 _ Load(sender作為對象,e作為EventArgs)處理MyBase。將Dim文件作為ObjectModel加載。readonly collection(Of String)= My。computer . File system . get Files(“C:\ ABC“)Dim FileSize As Long,FileName As String = Nothing Dim of FileSize As Long For Files As String In Files of FileSize = Mycomputer . File system . getfileinfo(文件)。長度(如果損壞)》FileSize Then FileSize = oFileSize FileName = File End If Next Dim ListN As listview item = New listview item(My。Computer.FileSystem.GetName(文件名)。子項。添加(oFileSize & amp“字節”)列表。添加(我的。computer . file system . getfileinfo(文件名)。擴展和擴展。“file“)listn . subitems . add(文件名)listview 1 . items . add(listn)end subend類。

詳見源代碼!!