急!如何获取指定目录下所有文件和目录名称列表

hxcj 2003-01-09 08:09:48
如果我想得到指定目录下的文件和目录甚至是子目录下的文件和目录名称列表清单,用什么方式可以实现?用dir等命令只能获得当前目录下的文件名列表,且不是按行排列!
如果可能用控件也可以,但是VFP的类似控件似乎功能太少了
...全文
215 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hax123 2003-01-09
  • 打赏
  • 举报
回复
你拿那个的目的是什么呢,
用getfile()就可以拿到你要的文件
marki 2003-01-09
  • 打赏
  • 举报
回复
ADIR( ) Function
Example See Also

Places information about files into an array and then returns the number of files.

Syntax

ADIR(ArrayName [, cFileSkeleton [, cAttribute]])

Returns

Numeric

Arguments

ArrayName

Specifies the name of the array. If the array you include doesn't exist, Visual FoxPro automatically creates the array. If the array exists and isn't large enough to contain all the information, Visual FoxPro automatically increases the size of the array to accommodate the information. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists and ADIR( ) returns 0 because no matching files are found, the array remains unchanged. If the array doesn't exist and ADIR( ) returns 0, the array isn't created.

The following table describes the contents and data type of each column in the array:

Column Array contents Data type
1 File names Character
2 File sizes Numeric
3 Dates last modified Date
4 Times last modified Character
5 File attributes Character


The last array column contains the file attributes of the matching files. Each file attribute is expressed by a letter; a file can have more than one attribute. The following table indicates the file attribute represented by each letter:

Letter Attribute
A Archive – Read/Write
H Hidden
R Read-only
S System
D Directory


cFileSkeleton

Specifies a file skeleton so you can store information about files with names or extensions that match a search criterion. For example, the criterion can be all tables, all text files, all files with names that have A as their first letter, and so on. Such general searches are done by including the wildcards * and ? in cFileSkeleton. A question mark represents a single character; an asterisk represents any number of characters. You can use any number of wildcards in any position within the file skeleton.

You can specify a drive and/or directory to search in for matching file names. If you don't specify a drive and directory, Visual FoxPro places information about files in the current directory into the array.

cAttribute

Specifies the inclusion of subdirectories and hidden or system files.

cAttribute can contain any combination of D, H, and S. Including D returns subdirectory names of the current directory in addition to file names that match the file skeleton specified in cFileSkeleton. Including H returns information about hidden files that match the file skeleton specified in cFileSkeleton. Including S returns information about system files that match the file skeleton specified in cFileSkeleton.

Include an empty string in cFileSkeleton to return just subdirectory names, hidden files or system files.

You can include V in cAttribute to return the volume name of the current drive. Only the volume name is returned to the array if V is included with D, H, or S. The volume name is stored in the first array element and the remainder of the array is truncated.

Remarks

For each file, ADIR( ) places into the array the file name, size, date last modified, time last modified, and attributes.
gosea 2003-01-09
  • 打赏
  • 举报
回复
*******用于遍历当前目录下的所有子目录,并以数据表的形式返回所有子目录
*******参数:cDrivePath 用于统计的当前目录
*******参数:dbfDirIndex 程序返回的目录表
*******参数:nDirCount 用于存诸遍历所得到的目录数目
PROCEDURE GetAllDir
Parameters cDrivePath,cDirIndexDBF
cDrivePath='C:' &&需扫描的盘符
use
Create Cursor dbfDirIndex (wjmc c(120),wjcd n(10),wjrq d,wjshj c(10),wjsx c(6))
xGS=1
xCD=0
append BLANK
REPL wjmc WITH cDrivePath
do while !eof()
nRecn=Recn()
cDrivePath=allt(wjmc)+'\'
x=adir(Mysz,(cDrivePath+'*.*'),'rashd')
* thisform.label1.caption="正在处理:"+alltrim(cDrivePath)
if x<>0
for I=3 to x
Mysz(I,1)=cDrivePath+Mysz(I,1)
xGS=xGS+1
xCD=xCD+Mysz(I,2)
endf
append from array Mysz for allt(wjmc)<>'.' AND allt(wjmc)<>'..' and 'D'$wjsx

endi
go nRecn
skip
endd
sele dbfDirIndex
nDirCount=reccount()
*brow
*use
return
酷窗版演示:http://www.edd8.com/bbs/index.asp?style=0 简装版演示:http://www.edd8.com/bbs/index2.asp 一点点论坛(http://www.edd8.com/bbs)使用说明 欢迎大家下载使用一点点论坛,在使用论坛前,请认真阅读以下内容: ===================================== 论坛:一点点论坛(http://www.edd8.com/bbs) 主页:一点点星空驿站(http://www.edd8.com/) 站长:叮咚虫(e_Mail:b_li@163.com) 版本:EDD8 Ver.2003 for DV =====================================   一点点论坛是建立在动网论坛基础上的ASP互动论坛,从动网Var5.b109开始论坛结构便开始脱离动网,与动网升级一起,本论坛本身也同时实现了动网新的功能,到519的发布,本人常得论坛本身已功能基本完善,所以决定与动网完全脱离,到动网Final的出现,本论坛也决定不再跟随动网升级了,本人全面对原来的论坛进行了代码优化和版面重排,并升级了部分功能代码,完成了现在这样的论坛。使论坛已经完全脱离了动网,以后也不可以随动网一起升级了!   所以选择本论坛的朋友请先明白,如果采用了本论坛的数据结构,以后就不可以和动网一起升级了,而现有的动网Final版的数据库和本论坛的数据库也是不兼容的!对于动网V5.b519的用户,本人同时在压缩包里提供了升级文件,可以把你519的数据库升级成和本论坛一致的数据结构!   由于一些朋友催得较,部分功能还是没有完善的(但不会出错),我以后也会给出升级包的。所以决定使用本论坛的朋友,请一定要到本站论坛的“站务办公室”进行指定的留言签名,以好我第一时间通知大家升级!   论坛中使用到的部分插件并没有一同奉上,原因是我还没完成代码优化,请过几天到我的论坛上下载。可以下载的插件主要有:社区银行、网络拳皇、可乐吧台球、五子棋等等…… ===================================== 主要特色功能说明: ◎ 双版面设计,用户可以根据不同爱好选择不同的版式(酷窗版和精简版),系统会记录用户的选择,不用重复选择,也不会出现版面混淆等现象; ◎ 发贴回贴互动功能,给用户随机的互动事件,增加用户的参与兴趣; ◎ 增强的UBB代码和JS代码,新增的买卖贴、定时贴等十几种特色功能UBB代码; ◎ 贴子功能加强,增加互动鲜花、鸡蛋、金钱、炸弹等功能,并保存数据作为用户在论坛的人缘依据; ◎ 不好说了,等你去发掘吧,不然又说我叫卖了…… ====================================== 安装说明: 解压就可以了,数据库名称和路径有变动时不要忘了在CONN。ASP中进行相应修改。 (注意:当论坛中一个贴子也没有时,论坛明星会出错,但当你加入贴子后就正常了,大家不要惊慌) 升级:(对519),解压后把你的原519数据库覆盖现数据库,再执行根目录下的UPDATE。ASP文件就行了,如果没有升级成功的提示,说明你的数据不能进行升级! (注意:数据库的升级应做了备份,并在本机上进行!) ====================================== 最后一点说明: 由于论坛本来是打算自己用的,所以在设计的过程中部分变量已经去掉,不能从后台设置了(如表格边框),请大家最好保持现有的风格。 如果还不问题,可以到我的论坛上来交流。??注意,由于本人时间不限,技术支持是有限的,请不要过于强求!

2,749

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧