Vishal
Vishal

Reputation: 6368

Get the file from a folder by file number in asp.net

I want to get the specific file from the folder depending on its number. For example I want the 3rd file from the folder ASP in c: drive or I want 10th file from the same folder then how can I get that using VB.NET?

I have tried the following code but I don't know for the specific file.

Dim Files() As String
Files = IO.Directory.GetFiles("C:\VB")

Upvotes: 1

Views: 463

Answers (1)

Santosh Panda
Santosh Panda

Reputation: 7341

!st get all the files from the Directory & store it in an Array. After that use FileInfo class to get the specific file by just passing the desired file number.

Dim arr As String() = System.IO.Directory.GetFiles("C:\VB")
Dim file As New FileInfo(arr(5))

Upvotes: 2

Related Questions