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!
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")
The static methods in Directory class and File class should be all you need.
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);
精彩评论