Q&A

  • 절실한 도움 요청~~~.
파일을 검색해서 파일의 정보를 알아내는데요, 한 번 검색하고 나서 다른 파일을 찾아서 결과값은 처음 찾은 데이터값만 나오네요, 고수님들의 도움좀,,,



unit find;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;



type

TForm1 = class(TForm)

searchedit: TEdit;

lstserver: TListBox;

Button1: TButton;

lstc: TListBox;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

procedure Button1Click(Sender: TObject);



private

{ Public declarations }

public

procedure filessearch (directory, seaRchname:string);

procedure filessearch1(directory, seaRchname:string);

end;



var

Form1: TForm1;



implementation



{$R *.DFM}

var sr : tsearchrec;

sr1 : tsearchrec;

r : integer;

r1 : integer;



procedure TFORM1.filessearch(directory, searchname:string);

begin



if directory[length(directory)] <> '' then

directory := directory + '';

r := sysutils.FindFirst(directory + searchname, faanyfile, sr);

// ShowMessage(sr.Name+' '+IntToStr(sr.Size)+'byte '+DateTimeToStr(FileDateToDateTime(sr.Time)));



while r = 0 do begin

if (sr.attr <> fadirectory) and (sr.name[1] <> '.') then

if sr.FindData.cAlternateFileName <> '' then

lstserver.ITEMS.ADD(DIRECTORY + SR.FindData.cAlternateFileName )

ELSE

lstserver.ITEMS.ADD(DIRECTORY + SR.FindData.cFileName );

APPLICATION.ProcessMessages;

R := SYSUTILS.FindNext(SR);

END; //WHILE

SYSUTILS.FindClose(SR);



IF FINDFIRST(DIRECTORY + '*.*', FADIRECTORY, SR) = 0 THEN begin

REPEAT

IF ((SR.ATTR AND FADIRECTORY) = FADIRECTORY) AND

(SR.Name[1]<>'.') THEN BEGIN

FILESSEARCH(DIRECTORY + SR.Name + '', SEARCHNAME);

END;

APPLICATION.ProcessMessages;

UNTIL (FINDNEXT(SR) <> 0);

END;



SYSUTILS.FindClose(SR);

END;



procedure TFORM1.filessearch1(directory, searchname:string);

begin



if directory[length(directory)] <> '' then

directory := directory + '';

r1 := sysutils.FindFirst(directory + searchname, faanyfile, sr1);

// ShowMessage(sr1.Name+' '+IntToStr(sr1.Size)+'byte '+DateTimeToStr(FileDateToDateTime(sr1.Time)));

while r1 = 0 do begin

if (sr1.attr <> fadirectory) and (sr1.name[1] <> '.') then

if sr1.FindData.cAlternateFileName <> '' then

lstc.ITEMS.ADD(DIRECTORY + SR1.FindData.cAlternateFileName)

ELSE

lstc.ITEMS.ADD(DIRECTORY + SR1.FindData.cFileName);

APPLICATION.ProcessMessages;

r1 := SYSUTILS.FindNext(SR1);

END; //WHILE



SYSUTILS.FindClose(SR1);



IF FINDFIRST(DIRECTORY + '*.*', FADIRECTORY, SR1) = 0 THEN begin

REPEAT

IF ((SR1.ATTR AND FADIRECTORY) = FADIRECTORY) AND

(SR1.Name[1]<>'.') THEN BEGIN

FILESSEARCH1(DIRECTORY + SR1.Name + '', SEARCHNAME);

END;

APPLICATION.ProcessMessages;

UNTIL (FINDNEXT(SR1) <> 0);

END;



SYSUTILS.FindClose(SR1);

END;



procedure TForm1.Button1Click(Sender: TObject);

var

dirserver:string;

dirc:string;

itemserver : string;

begin

lstserver.clear;

lstc.clear;

dirserver := 'a:/'; // 원격 서버

dirc := 'c:/'; // 로컬 호스트

filessearch ( dirserver, searchedit.text);

filessearch1( dirc, searchedit.text);

if DateTimeToStr(FileDateToDateTime(sr.Time)) > DateTimeToStr(FileDateToDateTime(sr1.Time)) then

ShowMessage('서버에 있는 ')

else if

DateTimeToStr(FileDateToDateTime(sr.Time)) = DateTimeToStr(FileDateToDateTime(sr1.Time)) then

ShowMessage('화일의 크기가 동일합니다')

else

ShowMessage('서버에 있는 화일의 크기가 큽니다');





// ShowMessage(sr1.Name+' '+IntToStr(sr1.Size)+'byte '+DateTimeToStr(FileDateToDateTime(sr1.Time)));

// itemserver := lstserver.Items.CommaText;

// showmessage(itemserver);





// SYSUTILS.FindClose(SR);

// SYSUTILS.FindClose(SR1);

end;



end.

0  COMMENTS