vb.net 如何循环遍历目录列表? [英] vb.net how to loop through a directory listing?

查看:75
本文介绍了vb.net 如何循环遍历目录列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何遍历文件夹以获取列出的每个文件及其日期/时间?

How can I loop through a folder getting each file listed and when its date/time?

推荐答案

使用 DirectoryInfo.GetFiles() 并从 FileInfo 类中提取数据(Name、CreationTime 等).

Use DirectoryInfo.GetFiles() and extract the data (Name, CreationTime, etc.) from the FileInfo class.

我从 MSDN 页面此处粘贴了一些代码.

I've pasted some code from the MSDN page here.

Imports System
Imports System.IO
Public Class GetFilesTest
    Public Shared Sub Main()
        ' Make a reference to a directory.
        Dim di As New DirectoryInfo("c:\")
        ' Get a reference to each file in that directory.
        Dim fiArr As FileInfo() = di.GetFiles()
        ' Display the names of the files.
        Dim fri As FileInfo
        For Each fri In fiArr
            Console.WriteLine(fri.Name)
        Next fri
    End Sub 'Main
End Class 'GetFilesTest

这篇关于vb.net 如何循环遍历目录列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆