Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Number of files in a folder

Number of files in a folder

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Central_IT
    wrote on last edited by
    #1

    What is the best way to check for a particulair file in a folder? e.g. I want to count the number of files that start with say "temp" and have an extension of txt. In this example Folder = Temp Files = temp01.txt, report.txt, temp02.txt. In this example we would return a count of 2

    L 1 Reply Last reply
    0
    • C Central_IT

      What is the best way to check for a particulair file in a folder? e.g. I want to count the number of files that start with say "temp" and have an extension of txt. In this example Folder = Temp Files = temp01.txt, report.txt, temp02.txt. In this example we would return a count of 2

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Central_IT wrote:

      What is the best way to ...

      Depends on your definition of best. The easiest way would be based on the Directory.GetFiles(String, String) method, taking the Count of the array being returned. This however is not the least expensive one in terms of system load, as it is building an array of strings, which potentially could be huge and take long. The cheapest way would probably be based on calling the Win32 functions GetFirstFile() and GetNextFile(), which requires P/Invoke and a bit more code. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      modified on Friday, January 14, 2011 6:27 AM

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups