Board index » delphi » files and dirs
Vijt Vincent
![]() Delphi Developer |
Thu, 13 Mar 2003 03:00:00 GMT
|
Vijt Vincent
![]() Delphi Developer |
Thu, 13 Mar 2003 03:00:00 GMT
files and dirs
Hi,
I'm making a kind of Explorer and i need to know when i'm listing a file or How is it done, via the FileInfo or something Please help, Vincent. |
Thomas Nelvi
![]() Delphi Developer |
Thu, 13 Mar 2003 03:00:00 GMT
Re:files and dirsQuoteVijt Vincent <vi...@belgacom.net> wrote in message Quote> Hi, When using FindFirst() and FindNext() you can check the TSearchRec.Attr. if TSearchRec.Attr AND faDirectory > 0 then {this is a directory} HTH |
Dirk Claessen
![]() Delphi Developer |
Thu, 13 Mar 2003 03:00:00 GMT
Re:files and dirsVijt Vincent <vi...@belgacom.net> schreef in berichtnieuws 8qldvc$4q...@news1.skynet.be... Quote> Hi, extensions (e.g. c:\temp\xyz.abc.hjk) Anyway, see FindFirst/FindNext and TSearchRec. The field Attr contains faReadOnly $00000001 Read-only files Below is an example of how to enumerate files, given a wildcard, e.g. -- Dirk Claessens procedure EnumFiles( WildCard: string; FileList: TStrings; stripExtensions: |
Cooltal
![]() Delphi Developer |
Sat, 15 Mar 2003 03:00:00 GMT
Re:files and dirsThe Delphi help tells to use this method (assuming you iterate through items in a directory with TSearchRec): if (SearchRec.Attr and faDirectory) > 0 then Also, you can completely discard any directory- or other type items from faAnyFile - faDirectory or faAnyFile - faHidden etc. Even more, every directory (not root directories?) have two directories .. , which means the parent directory You should check for the existence of these in your loop and do the Here is a simple loop, clean code. --- procedure GetDirList(Dir: string); if not DirectoryExists(Dir) then begin Rec := FindFirst( Dir + '\*.*', faAnyFile, SR ); try while Rec = 0 do begin if SR.Name = '.' then {"dummy" directory; do nothing} else if SR.Name = '..' then {"parent dir" directory - put a Level Up-icon} else if (SR.Attr and faDirectory) > 0 then {the item is a directory; put a dir icon for it} else {a file is in question; put a file icon} Rec := FindNext(SR); end; finally end; -------------------------------- QuoteThomas Nelvik wrote: |
Deborah Pat
![]() Delphi Developer |
Sat, 15 Mar 2003 03:00:00 GMT
Re:files and dirsI can see the header of your post on my ISP's copy of the borland.public.delphi.oleautomation newsgroup, but it hasn't been sent to Borland's news server. That means that most of the people who read Borland's newsgroups cannot see your post. To post messages that other people will see, you If you cannot connect directly to newsgroups because -- |