아래의 소스에서 궁금한게 있는데요..
좀만 봐주세요.... 질문은 소스 밑에 있습니다.....^^;
===================================================================================
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.FormShow(Sender: TObject);
begin
FTPTimer.Enabled := False;
FTPTimer.Interval:= 1000; //30초 단위
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;
<*** while FileExists(to_date + IntToStr(count)+'.txt') do <<=== 이부분인데요...
다름이 아니라 여기에 지금 로컬 폴더의 경로가 들어가 있는데..FTP의 서버경로는어찌알아서 넣어야 되나요??
begin
NMFTP1.Download((to_date + IntToStr(count)+'.txt'), ('C:A' + (to_date + IntToStr(count)) + '.txt'));
inc(count); // ".txt"파일 1씩 증가..
end; ***>
FTPTimer.Enabled :=True;
end;
===================================================================================
바로 위에 While 문에서 지금 FileExists함수를 사용했는데요..
그럼 FTP서버의 홈디렉토리 알아 내는 방법은 없나요??? 그래야 While문을 돌려서리 텍스트파일의 유무를 체크하는데요??? 고수님들 좀만 갈켜 주세요???
그리고 다음에는 FTP서버에서 다운 받은 파일을 Delete함수를 사용해서 서버의 홈디렉토리에 있는 차례대로 다운받은 텍스트파일을 지워야 하는데 어디에 넣어야 하는지요??
꼭 멋지고 시원한 답변 부탁드립니다.... 좀 급한거라.
빠른 답변 부탁드립니다....^^;
님들 즐거운 오후 보내세요...
델파이 Demos폴더에 예제가 있는데 그거 보시면 충분히 하실 수 있습니다.
TNMFTP.List메소드를 호출하시면 OnListItem이벤트가 발생하면서 폴더에 있는 파일들을
알려줍니다. TStringList같은데다가 저장해놓고 사용하세요...
폴더 바꾸는것은 TNMFTP.ChangeDir메소드를 사용하세요...
가급적이면 급하다는 말은 하지 않으시는것이 좋을겁니다...
^^ 항상 즐코하세요..
델초짜이고 차츰 알아가는 놈... 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.FormShow(Sender: TObject);
> begin
> FTPTimer.Enabled := False;
> FTPTimer.Interval:= 1000; //30초 단위
> 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;
>
> <*** while FileExists(to_date + IntToStr(count)+'.txt') do <<=== 이부분인데요...
> 다름이 아니라 여기에 지금 로컬 폴더의 경로가 들어가 있는데..FTP의 서버경로는어찌알아서 넣어야 되나요??
> begin
> NMFTP1.Download((to_date + IntToStr(count)+'.txt'), ('C:A' + (to_date + IntToStr(count)) + '.txt'));
> inc(count); // ".txt"파일 1씩 증가..
> end; ***>
> FTPTimer.Enabled :=True;
> end;
> ===================================================================================
> 바로 위에 While 문에서 지금 FileExists함수를 사용했는데요..
> 그럼 FTP서버의 홈디렉토리 알아 내는 방법은 없나요??? 그래야 While문을 돌려서리 텍스트파일의 유무를 체크하는데요??? 고수님들 좀만 갈켜 주세요???
> 그리고 다음에는 FTP서버에서 다운 받은 파일을 Delete함수를 사용해서 서버의 홈디렉토리에 있는 차례대로 다운받은 텍스트파일을 지워야 하는데 어디에 넣어야 하는지요??
> 꼭 멋지고 시원한 답변 부탁드립니다.... 좀 급한거라.
> 빠른 답변 부탁드립니다....^^;
> 님들 즐거운 오후 보내세요...