回复 21楼 hyswcyh
你不是说用表速度慢吗,怎么现在想用表了。
Function ScanFile3(cDrv) Local ss, cmd, temp ss = Seconds() Set Library To myfll.fll temp = sys(2015) + '.txt' cmd = '/c dir ' + cDrv + ' /s/a:-d/b >' + temp ShellExecWait('cmd', cmd, 0) Create Cursor sf3 (name V(250)) Append From (temp) sdf Erase (temp) ? Textmerge(' <<cDrv>> 找到 <<Recc()>> 个文件,耗时 <<Seconds()-ss>> 秒') EndFunc
Function ScanFile3(cDrv) Local ss, cmd, temp, nd, cExact ss = Seconds() temp = sys(2015) + '.txt' cmd = '/c dir ' + cDrv + ' /s/a/-c/o:gn >' + temp Set Library To myfll.fll ShellExecWait('cmd', cmd, 0) Create Cursor sf3 (date C(12), time C(9), size C(15), name V(250)) Append From (temp) sdf Erase (temp) Select Cast(date as D) date, Cast(time as C(5)) time, Cast(Alltrim(size) as V(10)) size, name ; from sf3 where (date not Like ' %') and (name not in ('.', '..')) into cursor sf3 cExact = Set("Exact") Set Exact off Count to nd for size = '<' Set Exact &cExact ? Textmerge(' <<cDrv>> <<Recc()-nd>> 个文件,<<nd>> 个文件夹,耗时 <<Seconds()-ss>> 秒') EndFunc
[此贴子已经被作者于2018-7-26 13:11编辑过]
******************************************************************************** ***功能:遍历指定盘符下的所有文件及文件夹,并获取所有相关信息。 ***文件名:ScanFileTol.Prg ***调用格式:ScanFileTol('D:') ******************************************************************************** PARAMETERS cDrvmc cDrvmc=UPPER(ALLTRIM(cDrvmc)) nOldsec=SECONDS() ? ? '[ '+cDrvmc+' ]开始扫描...',DATETIME() DIMENSION MyarrDir(1,5),MyarrFile(1,5),MyarrErr(1) MyarrDir(1,1)=ADDBS(cDrvmc) MyarrDir(1,2)='' MyarrDir(1,3)=DATE() MyarrDir(1,4)=TIME() MyarrDir(1,5)='....D' STORE 1 TO nCountDir STORE 0 TO nCountFile,nCountErr nIarr=1 DO WHILE nIarr<=nCountDir nNum=ADIR(Myarrtmp,MyarrDir(nIarr,1)+'*.*','RASHD') IF nNum < 1 nCountErr = nCountErr + 1 DIMENSION MyarrErr[nCountErr] MyarrErr[nCountErr] = "Error:" + MyarrDir(nIarr,1) ELSE FOR I=IIF(nIarr<=1,1,3) TO nNum IF 'D'$Myarrtmp(I,5) Myarrtmp(I,1)=MyarrDir(nIarr,1)+Myarrtmp(I,1)+'\' nCountDir=nCountDir+1 DIMENSION MyarrDir(nCountDir,5) FOR ai=1 TO 5 MyarrDir(nCountDir,ai)=Myarrtmp(i,ai) ENDFOR ELSE Myarrtmp(I,1)=MyarrDir(nIarr,1)+Myarrtmp(I,1) nCountFile=nCountFile+1 DIMENSION MyarrFile(nCountFile,5) FOR ai=1 TO 5 MyarrFile(nCountFile,ai)=Myarrtmp(i,ai) ENDFOR ENDIF ENDFOR ENDIF nIarr=nIarr+1 ENDDO ? '[ '+cDrvmc+' ]扫描完成...',DATETIME() ? '[ '+cDrvmc+' ]共找到[ '+TRANSFORM(nCountFile+nCountDir)+' ]个对象,其中文件[ '+TRANSFORM(nCountFile)+' ]个,文件夹[ '+TRANSFORM(nCountDir)+' ]个!用时[ '+TRANSFORM(SECONDS()-nOldsec)+' ]秒!' CREATE CURSOR Mydbf (wjmc C(254),wjcd N(20),wjrq D,wjshj C(10),wjsx C(6)) APPEND FROM ARRAY MyarrDir APPEND FROM ARRAY MyarrFile APPEND FROM ARRAY MyarrErr
[此贴子已经被作者于2018-7-27 08:11编辑过]