VBA lists all subfolders in the folder
Sub showfolderlist () <br/> dim FSO as object, ofolder as object <br/> dim ofolderarray as object, f As object <br/> dim K & </P> <p> set FSO = Createobject ("scripting. fileSystemObject ") <br/> set ofolder = FSO. getfolder ("C:/Program Files") <br/> set ofolderarray = ofolder. subfolders <br/> for each F in ofolderarray <br/> K = k + 1 <br/> cells (k, 1) = F. name <br/> next </P> <p> end sub
VBA list all files in the folder
Sub mydir () <br/> dim mydir as string <br/> dim I & <br/> range ("A: "). clearcontents <br/> mydir = Dir (thisworkbook. path &"/*. * ", vbnormal) <br/> do while mydir <>" "<br/> I = I + 1 <br/> cells (I, 2) = mydir <br/> mydir = dir <br/> loop <br/> end sub
Vsto lists all subfolders and files in a folder (C #)
Int I = 0, K = 0; <br/> directoryinfo dir = new directoryinfo (@ "C:/Windows"); <br/> directoryinfo [] dirs = dir. getdirectories (); <br/> foreach (directoryinfo folder in dirs) <br/>{< br/> I ++; <br/> This. range ["A" + I, missing]. value2 = folder. name; <br/>}< br/> fileinfo [] files = dir. getfiles (); <br/> foreach (fileinfo file in files) <br/>{< br/> K ++; <br/> This. range ["B" + k, missing]. value2 = file. name; <br/>}