当前位置: 代码迷 >> PB >> 怎样得到服务器上目录中的所有文件名?解决方案
  详细解决方案

怎样得到服务器上目录中的所有文件名?解决方案

热度:21   发布时间:2016-04-29 09:02:39.0
怎样得到服务器上目录中的所有文件名?

服务器:192.168.0.1

客户机:192.168.0.2

要在客户机(192.168.0.2)上得到服务器(192.168.0.1)的d:\aaa\logs目录下面所有的后缀名为.log的文件名称,并把这些文件名称(包括后缀名)显示到数据窗口dw_1中,应该怎样编写程序呢??


------解决方案--------------------
一、写socket程序进行通讯;
二、如果是SQLSERVER,通过存储过程执行DOS命令,可以得到
exec master..xp_cmdshell ''dir d:\aaa\logs'' 
将存储过程生成数据窗口即可~~
------解决方案--------------------
如果是PB,用DirList .

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 listTo 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 value 

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.)
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.


示例:

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_filespec

s_filespec = "*.TXT"

lb_filelist.DirList(s_filespec, 16400, st_filepath)
  相关解决方案