File list

I have file names in TXT file (1 name = 1 line). Now I need to compare file list in TXT with files in C:\WINDOWS and write to Memo names of files, which are new or added.
Delphi 3
Step by step, please...
pipigrilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
hi pipigril,

read the textfile in a tstringlist
read the filenames in a tstringlist (findfirst/findnext)

now go through the file-Tstringlist and lookup in the text-Tstringlist with the indexof-method

if the result < 0 then add the filename to your memo

meikl
0
edeyCommented:
or you could call command.com to pipe a dir c:\windows\*.* to a text file & load that, though the findFirst/findNext method would prob. be cleaner.

Gl
Mike
0
ckanetaCommented:
or you could use a TFileListBox compnent, point it at the appropriate
directory, and read a line of the file
and compare that to the lines in the component
0
ckanetaCommented:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes,
  Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, FileCtrl;

type
 TForm1 = class(TForm)
  fils: TFileListBox;
  Btn: TButton;
  Memo1: TMemo;
  Memo2: TMemo;
  procedure FormCreate(Sender: TObject);
  procedure BtnClick(Sender: TObject);
  private
   procedure loadfl;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
{------------------------------------------------------------------------------}
procedure TForm1.FormCreate(Sender: TObject);
 begin
  fils.Directory:='c:\windows';
  memo1.lines.clear; memo2.lines.clear;
  loadfl;
 end;
procedure TForm1.loadfl;
var ifl:Textfile; tmp:string;
 begin
  assignfile(ifl,ExtractFilepath(application.exename)+'fillst.txt'); reset(ifl);
  while not EOF(ifl) do begin
   readln(ifl,tmp);
   memo2.Lines.Add(tmp);
  end;
  closefile(ifl);
 end;
{------------------------------------------------------------------------------}
procedure TForm1.BtnClick(Sender: TObject);
var c:integer;
 begin
  for c:= 0 to fils.Items.count-1 do begin
   if memo2.Lines.IndexOf(fils.items[c]) = -1 then memo1.lines.add(fils.items[c]);
  end;
 end;

end.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.