Wednesday, July 3, 2013

asp.Net / vb.Net - how to get file list in a folder in asp.net

to get the file list in a folder using asp.net,
use the following code block

Dim dir As New DirectoryInfo("D:\foldername")
Dim dirinfo As FileInfo() = dir.GetFiles("*.pdf")
Dim FileName As FileInfo
Dim path As String
If dir.Exists = True Then
 For Each FileName In dirinfo
  path = dir.FullName & "\" & FileName.ToString
   'do something
 Next
End If

No comments:

Post a Comment