2020年5月22日 星期五

vb.net 列出資料夾裡的所有檔案名稱 [List all File Name]


1
2
3
4
5
6
7
8
9
Imports System
Imports System.IO



    Private Enum ListMode
        FullPath = 0
        FileName = 1
    End Enum







 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
    Private Function ListFile(pstrPath As String, psopType As SearchOption, plflMode As ListMode, Optional pstrExtension As String = "*") As ArrayList
        Dim DirInfo As New IO.DirectoryInfo(pstrPath)
        Dim FileInfo As IO.FileInfo() = DirInfo.GetFiles("*." & pstrExtension, psopType)
        Dim FileName As IO.FileInfo
        Dim arlReturn As New ArrayList

        For Each FileName In FileInfo
            If plflMode = ListMode.FileName Then
                arlReturn.Add(FileName)
            Else
                arlReturn.Add(FileName.FullName)
            End If
        Next

        Return arlReturn
    End Function

沒有留言:

張貼留言