在VFP8.0中,如何通过编程得到某已知文件夹中所有子文件夹名?
已知文件夹名及路径为 D:\ABCD ,在该文件夹中有5个子文件夹,在VFP8.0中,如何通过编程得到该文件夹中所有子文件夹名,并让变量A1、A2、A3、A4、A5分别等于5个子文件夹名。敬向专家请教,应如何编程求出变量A1、A2、A3、A4、A5的值,不胜感激!
[解决办法]
在FORM中增加MYPROC方法
代码:
LPARAMETERS Folder
fso=CREATEOBJECT("Scripting.FileSystemObject")
objFolder = fso.GetFolder(Folder)
For Each objFile In objFolder.Files
IF RIGHT(objFile.NAME,3)='DBF'
FF = FF + ' FROM "'+objFolder.path+'\'+objFile.NAME+'" UNION ALL SELECT * '
ENDIF
Next
For Each objFolder In objFolder.SubFolders
THIS.MYPROC(ObjFolder)
NEXT
click:
PUBLIC FF AS Character
FF=""
THISFORM.MYPROC("R:\TEMP")
FF1='SELECT *'+LEFT(FF,LEN(FF)-19)+' into curs dd'
&FF1
BROWSE
测试没有问题
[解决办法]
CLOSE DATABASES
SET DEFAULT TO ('D:\ABCD')
gnDbcnumber = ADIR(gaDatabase, '*.*','D') && Create array
CLEAR
FOR nCount = 1 TO gnDbcnumber && Loop for number of databases
? gaDatabase(nCount,1) && Display database names
ENDFOR
SET PATH TO HOME( ) && Set path to Visual FoxPro directory
[解决办法]
自行修改1楼代码,得到你需要的值,就是递归查询得到目录名、文件名
[解决办法]
你只要子文件夹名,更简单
在FORM中增加MYPROC方法
代码:
LPARAMETERS Folder
fso=CREATEOBJECT("Scripting.FileSystemObject")
objFolder = fso.GetFolder(Folder)
For Each objFolder In objFolder.SubFolders
ff=ff+objFolder.path
THIS.MYPROC(ObjFolder)
NEXT
click:
PUBLIC FF AS Character
FF=""
THISFORM.MYPROC("R:\TEMP")
取出FF中的值
BROWSE