TLISTVIEW component Displays files in the folder

zhaozj2021-02-16  61

procedure GetDirectories (list: TlistView; Directory: string; Item: Tlistitem; IncludeFiles: boolean); varSearchRec: TSearchRec; begin list.Items.BeginUpdate; // ready to update list.Items.Clear; // empty list content if Directory [length (Directory)] <> / 'THEN // Judgment Path Directory: = Directory ' / '; // Set Path IF Findfirst (Directory ' *. * ', Fadirectory, Searchrec) = 0 THEN Begin Repeat IF (SearchRec .Attr and fadirectory = fadirectory) and (searchRec.name [1] <>. ') The beginness (SearchRec.attr and fadirectory> 0) THEN BEGIN ITEM: = list.items.add; // Increase Item Item. Caption: = searchRec.name; item.imageIndex: = 6; end; getdirectories (List, Directory SearchRec.name, item, includefiles); end else if includefiles Then If SearchRec.name [1] <> '.' Then Begin Item: = list.items.add; item.caption: = searchRec.Name; item.imageIndex: = 6; END; Until FindNext (SearchRec) <> 0; // FindClose (SearchRec); end; list.items.endupdate;

Define Directory:

procedure makedir (modulname, pathname, dirname, filepath: string); // create a directory (a total of four, the lingua franca of friends if you feel you can add your own parameters) begintry if not directoryexists (frootpath modulname) then createdir (FRootPath modulname); if not DirectoryExists (FRootPath modulname '/' pathname) then createdir (FRootPath modulname '/' pathname); if not directoryexists (FRootPath modulname '/' pathname '/' dirname) then createdir ( FRootPath modulname '/' pathname '/' dirname); if filepath <> '' then if not directoryexists (FRootPath modulname '/' pathname '/' dirname '/' filepath) then createdir (FRootPath modulname '/' pathname '/' dirname '/' filepath) except On E: Exception do begin abort; end; end; banjin.N21.Enabled: = true; liucheng.MenuItem1.Enabled: = true; yanzheng. N21.Enabled: = true; banjin.SpeedButton1.Enabled: = true; liucheng.SpeedButton1.Enabled: = true; yanzheng.SpeedButton1.Enabled: = true; banjin.toolbutton1.Enabled: = true; liucheng.toolbutton1.Enabled: = True; yanzheng.toolbutto n1.Enabled: = true; if filepath = '' then filespath: = FRootPath modulname '/' pathname '/' dirname '/' filepath else filespath: = FRootPath modulname '/' pathname '/' DiRName '/' filepath '/'; banjin.statusbar1.panels [0] .text: = 'Your current location:' FileSpath;

Liucheng.statusbar1.panels [0] .text: = 'Your current location:' filespath; yanzheng.statusbar1.panels [0] .text: = 'Your current location:' filespath; end; if it is If the second or one-level directory, as long as the judgment of IF filepath <> 'TEN, for example: Makedir (' Design Specification ',' Electronic Parts ", 'Circuit Design Specification', '); Note : The two processes written here have not implemented the icon of the Windows. If you want to achieve this, you must write it yourself ^ _ ^

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

New Post(0)