How I can search a .txt file in any directory(i.e. c:\,d:\ etc.) using file functions in PowerBuilder?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With