2015年12月28日 星期一

asp.net 檔案列表-列出指定路徑下所有文檔、子資料夾

.VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    '取得路徑
    Dim dirinfo As DirectoryInfo = New DirectoryInfo(MapPath("~"))
    Dim sortList As FileInfo() = dirinfo.GetFiles()
  
    '取得目錄
    Dim sortFile As DirectoryInfo() = dirinfo.GetDirectories()
    For j As Integer = 0 To sortFile.Length - 1
        Label1.Text += sortFile(j).FullName & "<br/>"
    Next

    For Each item As FileInfo In sortList
        Label1.Text += item.FullName & "<br/>"
    Next
End Sub


沒有留言:

張貼留言