VB.Net 获取一个文件夹下多种格式的图片
Private Function GetImages(dirPath As String, ParamArray searchPatterns As String()) As String()
If searchPatterns.Length <= 0 Then
Return Nothing
Else
Dim di As New DirectoryInfo(dirPath)
Dim fis As FileInfo()() = New FileInfo(searchPatterns.Length - 1)() {}
Dim count As Integer = 0
Dim i As Integer = 0
While i < searchPatterns.Length
Dim fileInfos As FileInfo() = di.GetFiles(searchPatterns(i))
fis(i) = fileInfos
count += fileInfos.Length
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim files As String() = New String(count - 1) {}
Dim n As Integer = 0
Dim i As Integer = 0
While i <= fis.GetUpperBound(0)
Dim j As Integer = 0
While j < fis(i).Length
Dim temp As String = fis(i)(j).FullName
files(n) = temp
System.Math.Max(System.Threading.Interlocked.Increment(n),n - 1)
System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
End While
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Return files
End If
End Function
Dim files As String() = GetPictures("*.gif", "*.jpg", "*.png")
VB.net 选择文件夹
限制或禁止网页内容不被抓取而公开
欢迎关注微信公众账号ByCAD