Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all,

I have a situation here. I try to search in the internet but it doesn't work for me. The situation is I have declare a path and counting the existed file with that extension have. This are the code:

Dim path As String = "C:\FTP\Backup\"
Dim i As Integer
Dim FileCount As Integer = IO.Directory.GetFiles(path, "*.jpg").Length
'count the number of existing file with specific ext. in a path

Dim fileName(FileCount - 1) As String 'represent as array
Dim fileInfo As New FileInfo(path)

If FileCount <> 0 Then
    For i = 1 To FileCount
        fileName(i) = fileInfo.Name 'array will hold the file name from file info
End If

I don't know how to solve this. Let say I have 10 files with ".jpg" extension and I want to hold the filename in every count in an array so I can display it one by one. I know my code is not doing properly. Please help me..I stuck for 2days for this. Help me

1 solution

If all you want if the file names, why not just get them?
Dim matching As String() = Directory.GetFiles(path, "*.jpg")
Share this answer
Luiey Ichigo 16-May-12 3:55am    
Thanks Griff..solving my problem..5 for u and many2 thanks..
OriginalGriff 16-May-12 4:01am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900