遍历硬盘文件和文件夹查询文件或文件夹提速问题
这是学习了网上的遍历硬盘查询文件或文件夹的程序,修改的结果。就是运行速度太慢了,请各位大神给修改成纯数组操作,不用数据表(游标),可能会快一点。scanfile('d:','lkysics2018.exe','A','lkysics','D')
程序代码:
Parameter dqml,scanobj1,scanobj1type,scanobj2,scanobj2type dqml=upper(alltrim(dqml)) scanobj1=upper(alltrim(scanobj1)) scanobj1type=upper(alltrim(scanobj1type)) scanobj2=upper(alltrim(scanobj2)) scanobj2type=upper(alltrim(scanobj2type)) oldsec=SECONDS( ) valoldsec=oldsec ? '' ? dqml ? scanobj1 ? scanobj1type ? scanobj2 ? scanobj2type ? '准备工作开始...' Close Table All Create Cursor mylsdbf (wjmc C(254),wjcd N(20),wjrq D,wjshj C(10),wjsx C(6)) Append Blank Replace wjmc With dqml Do While !Eof() nRecn=Recno() dqml=Alltrim(wjmc)+'\' x=Adir(Mysz,(dqml+'*.*'),'rashd') If x <> 0 For I=3 To x Mysz(I,1)=dqml+Mysz(I,1) Endfor Append From Array Mysz For Alltrim(wjmc)<>'.' And Alltrim(wjmc)<>'..' Endif Go nRecn Skip Enddo Go Top oldseccc=alltrim(str(SECONDS( )-valoldsec)) valoldsec=SECONDS( ) ? '准备工作用时[ '+oldseccc+' ]秒!' ? '搜索目标开始...' Scan WAIT WINDOW '正在搜索[ ' + iif(len(ALLTRIM (wjmc))>150,left(ALLTRIM (wjmc),150),ALLTRIM (wjmc))+ " ]进程:"+alltrim(str(recno()))+"/" +alltrim(str(reccount())) NOWAIT if !empty(scanobj1) .and. !empty(scanobj1type) if (scanobj1 $ alltrim(wjmc)) .and. (scanobj1type $ wjsx) ? wjmc,wjcd,wjrq,wjshj,wjsx endif endif if !empty(scanobj2) .and. !empty(scanobj2type) if (scanobj2 $ alltrim(wjmc)) .and. (scanobj2type $ wjsx) ? wjmc,wjcd,wjrq,wjshj,wjsx endif endif EndScan Use oldseccc=alltrim(str(SECONDS( )-valoldsec)) valoldsec=SECONDS( ) ? '搜索用时[ '+oldseccc+' ]秒!' oldseccc=alltrim(str(SECONDS( )-oldsec)) ? '总用时[ '+oldseccc+' ]秒!'