Grabbing 1st file in directory

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

I am trying to "peak" (too bad that command is gone in VB.NET) into a
directory with 20000+ files and "grab" the first file, move it to a
new location, and continue the program operation. I am using VB.NET
2008 and have the following code snippet

Public inputFiles(1) As String
Public firstFile As String

inputFiles = Directory.GetFiles(inputDir)
firstFile = inputFiles(0)

--This works but takes a few seconds (time is very important) which is
unacceptable. I thought the following would work

Dim di As New IO.DirectoryInfo(inputDir)
Dim firstFullPath = di(1).FullPath

but this doesn't work either I receive a System.IO.DirectoryInfo
cannot be indexed because it has no default property. I vaguely
remember using the "peak" command back in "C" to look into a directory
and see the first file. Is there something like this in VB?

Once the first file is grabbed and processed the routine will be
called again and the "next" file will be grabbed which would be
another "peak" command.

Thanks!
 
Back
Top