Powerbuilder Request

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

+4
source share
2 answers

So, if everything you do is looking for files, you can do it with listbox.DirList (), or if you want to do it without being bound to a window or 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 need examples of how to use them, look in the PFC (Foundation PowerBuilder classes available on CodeXchange ) on the object (pfcapsrv. Pbl) pfc_n_cst_filesrvunicode.of_DirList (). (What is where these prototypes and structures are copied, BTW.)

Good luck

Terry

+6
source

You can use the ListBox control to get a list of files / directories based on a given string template (* .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 displaying it in a window visually.

 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 ) 
+3
source

Source: https://habr.com/ru/post/1307651/


All Articles