简体   繁体   中英

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")

Directory类File类中的静态方法应该是您所需要的。

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM