Posted By

simoncoder on 09/29/18


basic files directory vb visual directoryinfo

Versions (?)

Count Files in a directory

 / Published in: VB.NET

This function will return an INTEGER value of the number of files in a directory. to use this, just call the function with the location of the directory.

  1. Function CntFilesInDirectory(dirt As String)
  3. Dim S As String = dirt 'the location of the directoy ex: C:\TEST DIRECTORY\
  4. Dim d As New System.IO.DirectoryInfo(S)
  5. Dim intFiles As Integer
  6. intFiles = d.GetFiles.GetUpperBound(0) + 1
  7. Dim cnt As Integer
  8. cnt = intFiles + 1
  9. Return cnt
  11. End Function

Report this snippet  

You need to login to post a comment.