Q&A

  • [급급질문]FTP 소스부분의 이상한 반응???
====================================================================================

procedure TForm1.NMFTP1Success(Trans_Type: TCmdType);

begin

Case Trans_Type of

cmdChangeDir: StatusBar1.SimpleText := 'ChangeDir success';

cmdMakeDir: StatusBar1.SimpleText := 'MakeDir success';

cmdDelete: StatusBar1.SimpleText := 'Delete success';

cmdRemoveDir: StatusBar1.SimpleText := 'RemoveDir success';

cmdList: StatusBar1.SimpleText := 'List success';

cmdRename: StatusBar1.SimpleText := 'Rename success';

cmdUpRestore: StatusBar1.SimpleText := 'UploadRestore success';

cmdDownRestore: StatusBar1.SimpleText := 'DownloadRestore success';

cmdDownload: StatusBar1.SimpleText := 'Download success';

cmdUpload: StatusBar1.SimpleText := 'Upload success';

cmdAppend: StatusBar1.SimpleText := 'UploadAppend success';

cmdReInit: StatusBar1.SimpleText := 'ReInit success';

cmdAllocate: StatusBar1.SimpleText := 'Allocate success';

cmdNList: StatusBar1.SimpleText := 'NList success';

cmdDoCommand: StatusBar1.SimpleText := 'DoCommand success';

end;

end;







procedure TForm1.NMFTP1Connect(Sender: TObject);

begin

StatusBar1.SimpleText := 'Connected';

end;



procedure TForm1.NMFTP1Failure(var Handled: Boolean; Trans_Type: TCmdType);

begin

Case Trans_Type of

cmdChangeDir: StatusBar1.SimpleText := 'ChangeDir failure';

cmdMakeDir: StatusBar1.SimpleText := 'MakeDir failure';

cmdDelete: StatusBar1.SimpleText := 'Delete failure';

cmdRemoveDir: StatusBar1.SimpleText := 'RemoveDir failure';

cmdList: StatusBar1.SimpleText := 'List failure';

cmdRename: StatusBar1.SimpleText := 'Rename failure';

cmdUpRestore: StatusBar1.SimpleText := 'UploadRestore failure';

cmdDownRestore: StatusBar1.SimpleText := 'DownloadRestore failure';

cmdDownload: StatusBar1.SimpleText := 'Download failure';

//cmdUpload: StatusBar1.SimpleText := 'Upload failure';

cmdAppend: StatusBar1.SimpleText := 'UploadAppend failure';

cmdReInit: StatusBar1.SimpleText := 'ReInit failure';

cmdAllocate: StatusBar1.SimpleText := 'Allocate failure';

cmdNList: StatusBar1.SimpleText := 'NList failure';

cmdDoCommand: StatusBar1.SimpleText := 'DoCommand failure';

end;

end;



procedure TForm1.NMFTP1Error(Sender: TComponent; Errno: Word;

Errmsg: String);

begin

ShowMessage('Error '+IntToStr(Errno)+': '+Errmsg);

end;



procedure TForm1.saveproc;

begin

//count := 1;

to_date := formatdatetime('yyyymmdd',now);

ftpfile:= to_date + IntToStr(count);

if FileExists('C:A' + (to_date + IntToStr(count))+ '.txt')= True then

//if FileExists('C:A' + ftpfile + '.txt')= True then

begin

Assignfile(READER,'C:A' + (to_date + IntToStr(count))+ '.txt');

//Assignfile(READER,'C:A' + ftpfile + '.txt');

reset(Reader);

readln(reader,s);

While not EOF(Reader) do

begin

readln(reader,s);

RichEdit1.Lines.Add(S);

end;

end;

end;



function GetFileList(const Path: string): TStringList;



var

I: Integer;

SearchRec: TSearchRec;

begin

//count := 1;

to_date := formatdatetime('yyyymmdd',now);

ftpfile:= to_date + IntToStr(count);

Result := TStringList.Create;

try

I := FindFirst(ftpfile + '.txt', 0, SearchRec);

while I = 0 do

begin

Result.Add((ftpfile + '.txt'));

I := FindNext(SearchRec);

inc(count);

end;

except

Result.Free;

raise;

end;

end;



procedure TForm1.FormShow(Sender: TObject);

begin

FTPTimer.Enabled := False;

FTPTimer.Interval:= 30000; //30초 단위

//count := 1;

to_date := formatdatetime('yyyymmdd',now);

ftpfile:= to_date + IntToStr(count);

NMFTP1.Host := '203.251.174.14';

NMFTP1.Port := 21;

NMFTP1.Timeout := 360000;

NMFTP1.UserID := 'guest';

NMFTP1.Password := 'guestcare';

try

NMFTP1.Connect;

except

On E:Exception do

if E.message='something'

then writeln('poo');

end;



NMFTP1.Download((to_date + IntToStr(count)+'.txt'), ('C:A' + ftpfile + '.txt')); <== 이부분에서 다른 ".txt"파일을 차례대로 count 1씩증가시켜가면서 받아 와야 하지 않나요??

GetFileList((to_date + IntToStr(count)+'.txt')); <== 이부분에서도 이렇게하면 모든텍스트파일을 차례대로 받아 오지 않나요??

saveproc;

inc(count); // ".txt"파일 1씩 증가..

FTPTimer.Enabled :=True;

end;

====================================================================================

제가 만든 프로그램내의 FTP접속 부분의 소스입니다....

이놈이 Inc(..)함수를 사용했는데도.... FTP서버에서 파일을 하나만 받아 오고 있어요.... FTP서버의 폴더에는 여러개의 ".txt"파일이 있는데요...

방법을 좀 갈켜 주세요...

왜 하나의 텍스트파일만 받아 올까요???

답답합니다.... 이 답답한 속을 확 뚫어줄만한 고수님들의 조언 부탁드립니다...

그럼 행복한 오후되세요!!!

1  COMMENTS
  • Profile
    최용일 2001.10.23 02:03
    안녕하세요. 최용일입니다.



    파일이름을 바꾼다고 다운로드가 저절로 되는것은 아닙니다...



    OnShow이벤트에서 첫번째 파일 다운로드 받고 Count를 +1증가 시켜서 인덱스 바꾸고



    타이머 이벤트 걸고 끝나도록 코딩되어 있는데요...



    알고리즘을 잘 생각해보세요... 이런경우는 루프를 이용하셔야 겠군요...



    ^^ 항상 즐코하세요...



    델초짜이고 차츰 알아가는 놈... wrote:

    > ====================================================================================

    > procedure TForm1.NMFTP1Success(Trans_Type: TCmdType);

    > begin

    > Case Trans_Type of

    > cmdChangeDir: StatusBar1.SimpleText := 'ChangeDir success';

    > cmdMakeDir: StatusBar1.SimpleText := 'MakeDir success';

    > cmdDelete: StatusBar1.SimpleText := 'Delete success';

    > cmdRemoveDir: StatusBar1.SimpleText := 'RemoveDir success';

    > cmdList: StatusBar1.SimpleText := 'List success';

    > cmdRename: StatusBar1.SimpleText := 'Rename success';

    > cmdUpRestore: StatusBar1.SimpleText := 'UploadRestore success';

    > cmdDownRestore: StatusBar1.SimpleText := 'DownloadRestore success';

    > cmdDownload: StatusBar1.SimpleText := 'Download success';

    > cmdUpload: StatusBar1.SimpleText := 'Upload success';

    > cmdAppend: StatusBar1.SimpleText := 'UploadAppend success';

    > cmdReInit: StatusBar1.SimpleText := 'ReInit success';

    > cmdAllocate: StatusBar1.SimpleText := 'Allocate success';

    > cmdNList: StatusBar1.SimpleText := 'NList success';

    > cmdDoCommand: StatusBar1.SimpleText := 'DoCommand success';

    > end;

    > end;

    >

    >

    >

    > procedure TForm1.NMFTP1Connect(Sender: TObject);

    > begin

    > StatusBar1.SimpleText := 'Connected';

    > end;

    >

    > procedure TForm1.NMFTP1Failure(var Handled: Boolean; Trans_Type: TCmdType);

    > begin

    > Case Trans_Type of

    > cmdChangeDir: StatusBar1.SimpleText := 'ChangeDir failure';

    > cmdMakeDir: StatusBar1.SimpleText := 'MakeDir failure';

    > cmdDelete: StatusBar1.SimpleText := 'Delete failure';

    > cmdRemoveDir: StatusBar1.SimpleText := 'RemoveDir failure';

    > cmdList: StatusBar1.SimpleText := 'List failure';

    > cmdRename: StatusBar1.SimpleText := 'Rename failure';

    > cmdUpRestore: StatusBar1.SimpleText := 'UploadRestore failure';

    > cmdDownRestore: StatusBar1.SimpleText := 'DownloadRestore failure';

    > cmdDownload: StatusBar1.SimpleText := 'Download failure';

    > //cmdUpload: StatusBar1.SimpleText := 'Upload failure';

    > cmdAppend: StatusBar1.SimpleText := 'UploadAppend failure';

    > cmdReInit: StatusBar1.SimpleText := 'ReInit failure';

    > cmdAllocate: StatusBar1.SimpleText := 'Allocate failure';

    > cmdNList: StatusBar1.SimpleText := 'NList failure';

    > cmdDoCommand: StatusBar1.SimpleText := 'DoCommand failure';

    > end;

    > end;

    >

    > procedure TForm1.NMFTP1Error(Sender: TComponent; Errno: Word;

    > Errmsg: String);

    > begin

    > ShowMessage('Error '+IntToStr(Errno)+': '+Errmsg);

    > end;

    >

    > procedure TForm1.saveproc;

    > begin

    > //count := 1;

    > to_date := formatdatetime('yyyymmdd',now);

    > ftpfile:= to_date + IntToStr(count);

    > if FileExists('C:A' + (to_date + IntToStr(count))+ '.txt')= True then

    > //if FileExists('C:A' + ftpfile + '.txt')= True then

    > begin

    > Assignfile(READER,'C:A' + (to_date + IntToStr(count))+ '.txt');

    > //Assignfile(READER,'C:A' + ftpfile + '.txt');

    > reset(Reader);

    > readln(reader,s);

    > While not EOF(Reader) do

    > begin

    > readln(reader,s);

    > RichEdit1.Lines.Add(S);

    > end;

    > end;

    > end;

    >

    > function GetFileList(const Path: string): TStringList;

    >

    > var

    > I: Integer;

    > SearchRec: TSearchRec;

    > begin

    > //count := 1;

    > to_date := formatdatetime('yyyymmdd',now);

    > ftpfile:= to_date + IntToStr(count);

    > Result := TStringList.Create;

    > try

    > I := FindFirst(ftpfile + '.txt', 0, SearchRec);

    > while I = 0 do

    > begin

    > Result.Add((ftpfile + '.txt'));

    > I := FindNext(SearchRec);

    > inc(count);

    > end;

    > except

    > Result.Free;

    > raise;

    > end;

    > end;

    >

    > procedure TForm1.FormShow(Sender: TObject);

    > begin

    > FTPTimer.Enabled := False;

    > FTPTimer.Interval:= 30000; //30초 단위

    > //count := 1;

    > to_date := formatdatetime('yyyymmdd',now);

    > ftpfile:= to_date + IntToStr(count);

    > NMFTP1.Host := '203.251.174.14';

    > NMFTP1.Port := 21;

    > NMFTP1.Timeout := 360000;

    > NMFTP1.UserID := 'guest';

    > NMFTP1.Password := 'guestcare';

    > try

    > NMFTP1.Connect;

    > except

    > On E:Exception do

    > if E.message='something'

    > then writeln('poo');

    > end;

    >

    > NMFTP1.Download((to_date + IntToStr(count)+'.txt'), ('C:A' + ftpfile + '.txt')); <== 이부분에서 다른 ".txt"파일을 차례대로 count 1씩증가시켜가면서 받아 와야 하지 않나요??

    > GetFileList((to_date + IntToStr(count)+'.txt')); <== 이부분에서도 이렇게하면 모든텍스트파일을 차례대로 받아 오지 않나요??

    > saveproc;

    > inc(count); // ".txt"파일 1씩 증가..

    > FTPTimer.Enabled :=True;

    > end;

    > ====================================================================================

    > 제가 만든 프로그램내의 FTP접속 부분의 소스입니다....

    > 이놈이 Inc(..)함수를 사용했는데도.... FTP서버에서 파일을 하나만 받아 오고 있어요.... FTP서버의 폴더에는 여러개의 ".txt"파일이 있는데요...

    > 방법을 좀 갈켜 주세요...

    > 왜 하나의 텍스트파일만 받아 올까요???

    > 답답합니다.... 이 답답한 속을 확 뚫어줄만한 고수님들의 조언 부탁드립니다...

    > 그럼 행복한 오후되세요!!!