列出指定目录下所有文件

Wayne-XY 2017-07-20 08:18:33
指定目录或驱动器下列出所有文件及文件夹下所有文件。上网找到一个列子,但出来的结果只是一级目录,连文件都没列出来,有高手帮指点一下或者给个例子吗
这是那个例子,感觉没错,但输出确实有些问题 ,是不是我调试的有问题 ?
http://blog.csdn.net/itwenping/article/details/5679628
邮箱zlt_wangyan@163.com
...全文
539 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hovoy 2017-07-23
  • 打赏
  • 举报
回复
引用 6 楼 zlt_wangyan 的回复:
[quote=引用 3 楼 hovoy 的回复:] [quote=引用 2 楼 r00_a2lBUR 的回复:] 关键代码: sDirList = "C:\*.*" ddlb_file.dirlist( sDirList, 1) sFile = ddlb_file.text 如果sFile是目录,就要再取一次此目录下的文件及目录。 迭代运行。
对,我做过。。[/quote] 求教,我小新手,对这个还不太明白,能否给个例子我研究一下。[/quote] 看看pb自带的帮助,就有简要的列子。我复制一段给你。 DirList PowerScript function Description Populates a ListBox with a list of files. You can specify a path, a mask, and a file type to restrict the set of files displayed. If the window has an associated StaticText control, DirList can display the current drive and directory as well. Controls ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox controls Syntax listboxname.DirList ( filespec, filetype {, statictext } )Argument Description listboxname The name of the ListBox control you want to populate. filespec A string whose value is the file pattern. This is usually a mask (for example, *.INI or *.TXT). If you include a path, it becomes the current drive and directory. filetype An unsigned integer representing one or more types of files you want to list in the ListBox. Types are: 0 – Read/write files 1 – Read-only files 2 – Hidden files 4 – System files 16 – Subdirectories 32 – Archive (modified) files 16384 – Drives 32768 – Exclude read/write files from the list To list several types, add the numbers associated with the types. For example, to list read-write files, subdirectories, and drives, use 0+16+16384 or 16400 for filetype. statictext (optional) The name of the StaticText in which you want to display the current drive and directory. Return Values Boolean. Returns true if the search path is valid so that the ListBox is populated or the list is empty. DirList returns false if the ListBox cannot be populated (for example, filespec is a file, not a directory, or specifies an invalid path). If any argument's value is null, DirList returns null. Usage You can call DirList when the window opens to populate the list initially. You should also call DirList in the script for the SelectionChanged event to repopulate the list box based on the new selection. (See the example in DirSelect.) Note Alternatives Although DirList's features allow you to emulate the standard File Open and File Save windows, you can get the full functionality of these standard windows by calling GetFileOpenName and GetFileSaveName instead of DirList. Examples This statement populates the ListBox lb_emp with a list of read/write files with the file extension TXT in the search path C:\EMPLOYEE\*.TXT: lb_emp.DirList("C:\EMPLOYEE\*.TXT", 0)This statement populates the ListBox lb_emp with a list of read-only files with the file extension DOC in the search path C:\EMPLOYEE\*.DOC and displays the path specification in the StaticText st_path: lb_emp.DirList("C:\EMPLOYEE\*.DOC", 1, st_path)These statements in the script for a window Open event initialize a ListBox to all files in the current directory that match *.TXT: String s_filespecs_filespec = "*.TXT"lb_filelist.DirList(s_filespec, 16400, st_filepath)
r00_a2lBUR 2017-07-22
  • 打赏
  • 举报
回复
引用 4 楼 zlt_wangyan 的回复:
[quote=引用 2 楼 r00_a2lBUR 的回复:] 关键代码: sDirList = "C:\*.*" ddlb_file.dirlist( sDirList, 1) sFile = ddlb_file.text 如果sFile是目录,就要再取一次此目录下的文件及目录。 迭代运行。
请问有例子吗,我大约明白使用dirlist 来做,dirlist里 【】就是目录,判断出【】继续进去,但如果有三级或四级等多级目录怎么办?我不太懂,看网上要使用递归或者什么的,但小白真心没研究明白[/quote]我没有做过这个,3#的有做过。
Wayne-XY 2017-07-22
  • 打赏
  • 举报
回复
引用 3 楼 hovoy 的回复:
[quote=引用 2 楼 r00_a2lBUR 的回复:] 关键代码: sDirList = "C:\*.*" ddlb_file.dirlist( sDirList, 1) sFile = ddlb_file.text 如果sFile是目录,就要再取一次此目录下的文件及目录。 迭代运行。
对,我做过。。[/quote] 求教,我小新手,对这个还不太明白,能否给个例子我研究一下。
r00_a2lBUR 2017-07-21
  • 打赏
  • 举报
回复
关键代码: sDirList = "C:\*.*" ddlb_file.dirlist( sDirList, 1) sFile = ddlb_file.text 如果sFile是目录,就要再取一次此目录下的文件及目录。 迭代运行。
Wayne-XY 2017-07-21
  • 打赏
  • 举报
回复
引用 2 楼 r00_a2lBUR 的回复:
关键代码: sDirList = "C:\*.*" ddlb_file.dirlist( sDirList, 1) sFile = ddlb_file.text 如果sFile是目录,就要再取一次此目录下的文件及目录。 迭代运行。
请问有例子吗,我大约明白使用dirlist 来做,dirlist里 【】就是目录,判断出【】继续进去,但如果有三级或四级等多级目录怎么办?我不太懂,看网上要使用递归或者什么的,但小白真心没研究明白
hovoy 2017-07-21
  • 打赏
  • 举报
回复
引用 2 楼 r00_a2lBUR 的回复:
关键代码: sDirList = "C:\*.*" ddlb_file.dirlist( sDirList, 1) sFile = ddlb_file.text 如果sFile是目录,就要再取一次此目录下的文件及目录。 迭代运行。
对,我做过。。
Wayne-XY 2017-07-20
  • 打赏
  • 举报
回复
我的想法是列出的目录样式 c:\ab.txt c.windows\123.txt c:\windows\system32\123.txt c:\windows\system32\abc\123.txt

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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