开发者

Visual Basic: Iterate a folder's files

开发者 https://www.devze.com 2023-02-02 22:09 出处:网络
I would like to iterate the files in a folder in Visual Basic. I want to check for each file\'s name开发者_开发百科. I heard about a Dir function or something, but I am not very sure how to use it..Im

I would like to iterate the files in a folder in Visual Basic. I want to check for each file's name开发者_开发百科. I heard about a Dir function or something, but I am not very sure how to use it..


Imports System.IO

Dim fInfo As FileInfo()                
Dim i As Integer = 0         
Dim path AS String = "INSERT FILE PATH"       
Dim dInfo As New DirectoryInfo = New DirectoryInfo(path)   

fInfo = dInfo.GetFiles("*.txt")              
Dim files As String()                
Dim File As String                
files = Directory.GetFiles(path, "*.txt")                
For Each File In files                        
   'Do Something With The File                 
   i += 1                
Next
0

精彩评论

暂无评论...
验证码 换一张
取 消