β

VB.NET / C# 遍历列出目录下所有文件

Forece Blog 25 阅读

VB.NET / C# 遍历列出目录下所有文件

VB 代码

Dim di As New DirectoryInfo("c:\temp")
        Dim info As FileSystemInfo
        For Each info In di.GetFiles
            System.IO.File.AppendAllText("c:\temp\test.txt", info.Name & vbCrLf)
        Next

C# 代码

DirectoryInfo TheFolder = new DirectoryInfo(@"c:\temp");
            FileInfo[] fileInfo = TheFolder.GetFiles();
            foreach (FileInfo NextFile in fileInfo)
                System.IO.File.AppendAllText(@"c:\temp\test.txt", NextFile.Name + "\r\n");
作者:Forece Blog
原文地址:VB.NET / C# 遍历列出目录下所有文件, 感谢原作者分享。

发表评论