Powerbuilder查询

发布于 2024-08-29 11:05:37 字数 61 浏览 1 评论 0原文

如何使用 PowerBuilder 中的文件函数在任何目录(即 c:\,d:\ 等)中搜索 .txt 文件?

How I can search a .txt file in any directory(i.e. c:\,d:\ etc.) using file functions in PowerBuilder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

_蜘蛛 2024-09-05 11:05:37

因此,如果您所做的只是查找文件,则可以使用 listbox.DirList() 来完成此操作,或者如果您想在不绑定到窗口或控件的情况下执行此操作,则可以调用 WinAPI 函数来执行此操作:

Function long FindFirstFileW (ref string filename, ref os_finddata findfiledata) library "KERNEL32.DLL" alias for "FindFirstFileW"
Function boolean FindNextFileW (long handle, ref os_finddata findfiledata) library "KERNEL32.DLL" alias for "FindNextFileW"

其中 os_finddata 定义为

unsignedlong        ul_fileattributes
os_filedatetime     str_creationtime
os_filedatetime     str_lastaccesstime
os_filedatetime     str_lastwritetime
unsignedlong        ul_filesizehigh
unsignedlong        ul_filesizelow
unsignedlong        ul_reserved0
unsignedlong        ul_reserved1
character       ch_filename[260]
character       ch_alternatefilename[14]

os_filedatetime 定义为

unsignedlong        ul_lowdatetime
unsignedlong        ul_highdatetime

如果您想要了解如何使用它们的示例,请查看 PFC(PowerBuilder 基础类,可在 CodeXchange) 位于对象 (pfcapsrv.pbl)pfc_n_cst_filesrvunicode.of_DirList () 处。 (顺便说一句,这些原型和结构就是从那里复制的。)

祝你好运,

特里

So, if all you're doing is looking for files, you can do this with a listbox.DirList(), or if you want to do this without being tied to a window or a control, you can call WinAPI functions to do this:

Function long FindFirstFileW (ref string filename, ref os_finddata findfiledata) library "KERNEL32.DLL" alias for "FindFirstFileW"
Function boolean FindNextFileW (long handle, ref os_finddata findfiledata) library "KERNEL32.DLL" alias for "FindNextFileW"

where os_finddata is defined as

unsignedlong        ul_fileattributes
os_filedatetime     str_creationtime
os_filedatetime     str_lastaccesstime
os_filedatetime     str_lastwritetime
unsignedlong        ul_filesizehigh
unsignedlong        ul_filesizelow
unsignedlong        ul_reserved0
unsignedlong        ul_reserved1
character       ch_filename[260]
character       ch_alternatefilename[14]

and os_filedatetime is defined as

unsignedlong        ul_lowdatetime
unsignedlong        ul_highdatetime

If you want examples of how to use these, look in PFC (PowerBuilder Foundation Classes, available at CodeXchange) at the object (pfcapsrv.pbl)pfc_n_cst_filesrvunicode.of_DirList (). (That's where these prototypes and the structures are copied from, BTW.)

Good luck,

Terry

梦回梦里 2024-09-05 11:05:37

您可以使用 ListBox 控件根据给定的字符串模式(*.txt、myfile.txt、.etc)获取文件/目录列表。查看帮助中的 DirList 函数。这是此处的示例如何使用 ListBox 控件而不将其直观地放在窗口上。

string ls_files[]
window lw_1
listbox llb_1
int li_items, li_i

Open( lw_1 )

lw_1.openUserObject( llb_1 )

llb_1.DirList( sFileSpec, uFileType )

li_items = llb_1.TotalItems()

For li_i = 1 to li_items

ls_files[ li_i ] = llb_1.Text( li_i )

Next

lw_1.closeUserObject( llb_1 )

Close( lw_1 )

You can use a ListBox control to get a list of files/directories based on a given string pattern (*.txt, myfile.txt, .etc). Look at the DirList function in the help. And here is an example from here showing how to use a ListBox control without putting it visually on a window.

string ls_files[]
window lw_1
listbox llb_1
int li_items, li_i

Open( lw_1 )

lw_1.openUserObject( llb_1 )

llb_1.DirList( sFileSpec, uFileType )

li_items = llb_1.TotalItems()

For li_i = 1 to li_items

ls_files[ li_i ] = llb_1.Text( li_i )

Next

lw_1.closeUserObject( llb_1 )

Close( lw_1 )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文