VB.Net - Check If Folder Contains Files

VB.Net - How To Check If Folder Contains Files Or Folders Using Visual Basic.Net

vb.net check if directory contains files


In This VB.Net Tutorial  We Will See How To Check If A Directory Contains Files Or Other Sub Directory Using Visual Basic.Net Programming Language.


Project Source Code:

Imports System.IO

Public Class Contain_Files_And_Folder

    Private Sub ButtonCheck_Click(sender As Object, e As EventArgs) Handles ButtonCheck.Click

        Dim path As String
        path = TextBox1.Text
        Dim files() As String
        Dim folders() As String

        If Directory.Exists(path) Then

            files = Directory.GetFiles(path)
            folders = Directory.GetDirectories(path)

            Label1.Text = files.Length & " File And " & folders.Length & " Folder "


        End If


    End Sub
End Class

//OutPut:

VB.Net - Check If Folder Contains Files





Share this

Related Posts

Previous
Next Post »