any a,b
string aa[],bb[]int li_i
f_traversal_file(sle_path.text,lb_1,ref a,ref b)
aa = a
bb = b
for li_i =1toupperbound(aa)
lb_2.additem(aa[li_i])
next
for li_i =1toupperbound(bb)
lb_3.additem(bb[li_i])
next
三、创建function方法,命名为f_traversal_file
global type f_traversal_file from function_object
end type
forward prototypes
global subroutine f_traversal_file (string as_path, listbox a_listbox, ref any as_arrfolder, ref any as_arrfile)
end prototypes
global subroutine f_traversal_file (string as_path, listbox a_listbox, ref any as_arrfolder, ref any as_arrfile);//======================================================//f_traversal_file//------------------------------------------------------//as_path : 文件夹路径//a_listbox : 可视化listbox控件(需要在界面上的,可以隐藏控件)//as_arrfolder : 返回文件夹路径数组//as_arrfile : 返回文件路径数组//======================================================int li_flag =0long ll_i,ll_j
boolean lb_boolean =true
string ls_filename,ls_path
string ls_arrfolder[],ls_arrfile[],ls_savefolder[]
listbox lb_listbox
ls_path = as_path
lb_listbox = a_listbox
lb_boolean =true
ls_savefolder[1]= ls_path
dowhile lb_boolean
li_flag =0for ll_i =1toupperbound(ls_savefolder)
ls_path = ls_savefolder[ll_i]ifisnull(ls_path) then ls_path = ''
if ls_path = '' then
if li_flag <>1 then li_flag =0elselb_listbox.DirList(ls_path +"\*.*",2+4+16)//for ll_j =1tolb_listbox.TotalItems()
ls_filename = lb_listbox.text(ll_j)if ls_filename ='[..]' then continue//[文件夹]ifleftw(ls_filename,1)='[' and rightw(ls_filename,1)=']' then
ls_filename =midw(ls_filename,2,lenw(ls_filename)-2)
ls_arrfolder[upperbound(ls_arrfolder)+1]= ls_path + '\' + ls_filename
ls_savefolder[upperbound(ls_savefolder)+1]= ls_path + '\' + ls_filename
li_flag =1else//文件
ls_arrfile[upperbound(ls_arrfile)+1]= ls_path + '\' + ls_filename
end if
next
end if
ls_savefolder[ll_i]= ''
next
if li_flag =1 then
lb_boolean =trueelse
lb_boolean =false
end if
loop
as_arrfolder = ls_arrfolder
as_arrfile = ls_arrfile
end subroutine