How to Find a File

  • Thread starter Thread starter Don Gollahon
  • Start date Start date
D

Don Gollahon

How can I find a file in .NET? I know I can use Directory.GetFiles()
with a path and mask like '*.txt' but our directories in production can
have 10's of thousands of files. I just want to get the first match to
the mask quickly without having to fill a huge array.

VS 2003, .NET 1.1.

Thanks.
 
How can I find a file in .NET? I know I can use Directory.GetFiles()
with a path and mask like '*.txt' but our directories in production can
have 10's of thousands of files. I just want to get the first match to
the mask quickly without having to fill a huge array.

To make sure I understand: a search pattern that when used to list just
the files in a single directory, without any recurision into
subdirectories, still retrieves an unacceptably large number of
filenames? You would prefer something that just returns a single filename
at a time?

I'm not aware of a .NET way to do that. You can use the unmanaged
FindFirstFile() function to achieve that though, and it should be simple
enough to incorporate that into your application via p/invoke.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top