Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

File listing source

Posted on 1997-11-02
2
Medium Priority
?
230 Views
Last Modified: 2010-04-16
Has anyone got source code for a file listing program that will allow me to do the following.
1) quick sorting procedure/function
2) Allow me to choose what files to display eg:- FileExts:=(txt,doc,diz,me), So that it will show files only with those extensions.
3) Long file name handling would be a bonus but optional.

I know this may be a big ask, But any help would be appreciated.

Many thanks in advance.
Renegade.
0
Comment
Question by:Renegade
2 Comments
 
LVL 1

Accepted Solution

by:
Odie earned 300 total points
ID: 1216421
uses WinDos, Strings;

const
 Directory: String
          = 'C:\';
 NrOfMasks = 3;
 Masks: array[1..NrOfMasks] of String
           = ('*.bat', '*.sys', '*.exe');

var
 SearchRec: TSearchRec;
 X: Integer;
 PC: PChar;

begin
 GetMem(PC, 256);
 for X := 1 to NrOfMasks do begin
   StrPCopy(PC, Directory + Masks[X]);
   FindFirst(PC, faAnyFile, SearchRec);
   while (DosError = 0) do begin
     WriteLn(SearchRec.Name);
     FindNext(SearchRec);
   end;
 end;
 FreeMem(PC, 256);
 ReadLn;
end.

This is sorted for each extension separatly.  I can sort it for all at once if necessary.

You can easily add size, attr. etc. (see TSearchRec in help)
0
 

Author Comment

by:Renegade
ID: 1216422
Thankyou for your help Odie. I should be able to use the routine in a dandy piece of snippet I found in the SWAG's to do what I want to do.

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Integration Management Part 2
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question