Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powerbuilder query

Tags:

powerbuilder

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

like image 920
Goodwill Avatar asked Jan 23 '23 05:01

Goodwill


1 Answers

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

like image 67
Terry Avatar answered Mar 15 '23 13:03

Terry