Delphi
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Delphi

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old May 12th, 2008, 10:21 AM
Rob Kennedy
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
file counting

mauro russo wrote:
is it possible to obtain the number of files in a directory (no sub-directories)
without to enumerate all files, for example as FindFirst and FindNext?

No. You have to count them.

A TFileListBox would be overkill. Even if it works non-visually, it
still needs to do all the work of enumerating the directory, and then it
has the overhead of storing the file information that you apparently
don't need.

When counting the files, make sure you remember to ignore the current
and parent directories (. and ).

--
Rob

Reply With Quote
  #2  
Old May 15th, 2008, 11:32 AM
Rob Kennedy
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
file counting

mauro russo wrote:
Rob Kennedy wrote:
>mauro russo wrote:

is it possible to obtain the number of files in a directory (no
sub-directories)
without to enumerate all files, for example as FindFirst and FindNext?
>>

>No. You have to count them.
>

how to be sure the files are read in alphabetical arrangement?

As the documentation for FindFirstFile says, if you want the files in a
particular order, you need to get all the names first and then put them
into the desired order yourself.

FindFirstFile and FindNextFile return files in whatever order the
filesystem driver provides them. It might be alphabetical, it might be the
order in which they were created, or it might be any other order you can
think of.

But why does the order matter? You're only counting them. You'll get the
same number no matter what order they're in.

--
Rob

Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Delphi > file counting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT