Results 1 to 2 of 2

Thread: No.of Files

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    INDIA
    Posts
    31

    No.of Files

    Hi all,

    In VB.NET how to find how many files are there in a folder.

    Can anyone help me in this regards

    Thanks in advance.

    Regards

    Nag K.
    Nagendra K

  2. #2
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Sure can, it's very easy. First you have to add this to the top of the form.

    VB Code:
    1. Imports System.IO

    Then create a new DirectoryInfo variable like the following:

    VB Code:
    1. Dim DirInfo as New DirectoryInfo([i]folderpath[/i])

    Substitute folderpath with the path of the folder you wish to find out how many files there are.
    Then use the following code to get the number of files in the folder:

    VB Code:
    1. [i]variable[/i] =  DirInfo.GetFiles().GetUpperBound(0)

    Hope this helps.

    Oooo, this was my 400th post, yey .
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width