Wednesday 4 June 2014

How to count files in Specific Folder using vb.net

Imports System.IO
=====================
Public Class Form2
    Dim Files() As String
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim path1 As String = "D:\scan"
        Dim dr As New DirectoryInfo(path1)
        If dr.Exists Then
            Dim res As Integer = FileCount(path1)
            For i As Integer = 0 To res - 1
                Dim st As String = (Replace(Files(i), path1 & "\", ""))
                Dim re As String = Replace(st, ".jpg", "")
            Next
        End If
    End Sub
    Public Function FileCount(ByVal FolderName As String) As Integer
        Files = IO.Directory.GetFiles(FolderName)
        Return Files.Length
    End Function
End Class




rs return:1,2,3


No comments:

Post a Comment

Followers