jayjyli
jayjyli

Reputation: 821

How to get a collection of files from Windows in VB.NET?

I'm trying to get a collection of children in a Windows folder in my VB program. I don't know what classes / methods to use. I could look it up but I wouldn't know what to search for and .NET has way too much documentation to wade through.

Thanks!

Upvotes: 1

Views: 654

Answers (3)

Gregory Nozik
Gregory Nozik

Reputation: 3374

DirectoryInfo - the class that has directory information

See example

  foreach (DirectoryInfo dir in di.GetDirectories())
                     dir.GetFiles

FileInfo - class that responsible for file represenattion

Namespace System.IO must be used

You can use static methods of File class

File.Copy(sourceFileName, tmpFileName, true);

Upvotes: 1

Josh Noe
Josh Noe

Reputation: 2797

Use the Directory.GetFiles method. This returns an array of strings of all the files found in a given directory:

Dim files as string() = Directory.GetFiles("C:\myfiles")

Upvotes: 2

Bala R
Bala R

Reputation: 108957

The static methods in Directory class and File class should be all you need.

Upvotes: 1

Related Questions