Traversal file

xiaoxiao2021-03-18  250

Function FindFilePath: string; var rfilename: string; sr: tsearchrec; fileattrs: integer;

begin Application.ProcessMessages; FileAttrs: = faDirectory; RFileName: = FileSearch (filename, path); if (RFileName = '') then begin if FindFirst (path '/*.*',FileAttrs,sr) = 0 then begin repeat IF ((sr.attr and fileattrs) = sr.attr) and (sr.name <> '.') and (sr.name <> ')) The begin // Recursively AA .Add (Path '/' sr.name); RFileName: = FindFilePath (Path '/' sr.name, FileName); if (RFileName <> ') THEN Begin Result: = RFileName; EXIT; END End; Until FindNext (SR) <> 0; FindClose (SR); end; end; result: = RFileName; END;

Procedure tForm1.Button1Click (Sender: Tobject); VAR i: integer; path: string; filepath: string; begin filepath: = '*. *'; aa: = tstringlist.create; path: = 'f: / netgame1 / big words Journey to Tour '; FindFilePath (PATH,'); ListBox2.Items: = aa; listbox1.items.add (PATH); SETCURRENTDIRECTORY (PCHAR (PATH)); SendMessage (ListBox1.Handle, LB_DIR, DDL, LPARAM (FilePath)) ; For i: = 0 to aa.count-1 do begin listbox1.items.add (aa.strings [i]); setCurrentDirectory (pchar (aa.strings [i])); sendMessage (Listbox1.handle, LB_Dir, DDL , Lparam (filepath)); end;

转载请注明原文地址:https://www.9cbs.com/read-129939.html

New Post(0)