VBA列出文件夹中所有的子文件夹
Sub ShowFolderList() Dim fso As Object, oFolder As Object Dim oFolderArray As Object, f As Object Dim k& Set fso = CreateObject("scripting.filesystemobject") Set oFolder = fso.GetFolder("C:/Program Files") Set oFolderArray = oFolder.SubFolders For Each f In oFolderArray k = k + 1 Cells(k, 1) = f.Name Next End Sub
VBA列出文件夹中所有的文件
Sub mydir() Dim mydir As String Dim i& Range("A:A").ClearContents mydir = Dir(ThisWorkbook.Path & "/*.*", vbNormal) Do While mydir <> "" i = i + 1 Cells(i, 2) = mydir mydir = Dir Loop End Sub
VSTO列出文件夹里所有的子文件夹和文件(C#)
int i = 0, k = 0; DirectoryInfo dir = new DirectoryInfo(@"c:/windows"); DirectoryInfo[] dirs = dir.GetDirectories(); foreach (DirectoryInfo folder in dirs) { i++; this.Range["a" + i, missing].Value2 = folder.Name; } FileInfo[] files = dir.GetFiles(); foreach (FileInfo file in files) { k++; this.Range["b" + k, missing].Value2 = file.Name; }
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
QQ咨询|关于我们|Archiver|手机版|小黑屋|( 辽ICP备15012455号-4 ) Powered by 期权论坛 X3.2 © 2001-2016 期权工具网&期权论坛 Inc.
下载期权论坛手机APP