我需要在BCB6程序中用到一次很简单的FTP文件检索,用的是NMFTP控件,在使用中我发现用“NMFTP1->FTPDirectoryList->ModifDate->Strings[i]”会根据当前年份不同返回的是如下两种不同的日期字符串:A:如果文件日期与当前年份相同则只返回"Jul 6 11:38 "这种格式不包含年份的字符串值;
B:如果文件日期与当前年份不同则返回的是"Jul 31 2003"这种格式不包含时间的字符串;而我需要的是一个月日年时分秒完整 TDateTime 型值,如(2004-6-28 22.09.33)这种!C++Builder 版人气实在不旺,所以过来求助于大家帮忙,希望大家多多捧场捧场!
B:如果文件日期与当前年份不同则返回的是"Jul 31 2003"这种格式不包含时间的字符串;而我需要的是一个月日年时分秒完整 TDateTime 型值,如(2004-6-28 22.09.33)这种!C++Builder 版人气实在不旺,所以过来求助于大家帮忙,希望大家多多捧场捧场!
解决方案 »
- 怀念Delphi,做了个网站,散分
- opendialog 中添加选项
- 为什么提示 Unsatisfied forward or external declaration
- QuickReport使用普通打印机没问题,使用专用打票打印机出错,程序都运行不起来,请问怎么解决~
- 我在Toolbar中放了几个SpeedButton按钮,隐藏几个后,后面的按钮无后自动向前靠?
- 录音程序(播放背景音乐+要录制音),做成混音效果。各位给点建议了,up有分
- 请问:如何判断某个日期是星期几?
- 那位大哥有五子棋之类的游戏源代码,给小弟传一个
- 花了几个月的时间,软件终于完成了。请大家多多捧场!!!!
- 我怎么运行程序,一下出来2个窗口,登陆和主窗体都出来了,为什么啊?
- delphi 6 中使用DesignEditors的单元中的Proxies到那里去找。
- 手机发短信的非一般问题!!!
Indy的IdFTP才有定制性你需要定制List方法为List -T参数才能获得完整时间修改IdFTP.pas的
Dest := TStringStream.Create(''); try {Do not translate}
if ADetails then begin
InternalGet('LIST -T', LDest); {Do not translate}
end else begin
InternalGet('NLST', LDest); {Do not trnalstate}
end;
List是FTP的命令
DOS下那个FTP.exe不能支持的最好看RFC959协议,就有很清楚的FTP命令
一般有以下那么多:
USER PORT RETR ALLO DELE SITE XMKD CDUP FEAT
PASS PASV STOR REST CWD STAT RMD XCUP OPTS
ACCT TYPE APPE RNFR XCWD HELP XRMD STOU AUTH
REIN STRU SMNT RNTO LIST NOOP PWD SIZE PBSZ
QUIT MODE SYST ABOR NLST MKD XPWD MDTM PROT还有一样要说就是目前没有那个FTP组件能支持带参数的List命令,所以必须自己修改IdFTP的源代码才能实现的你需要定制List方法为List -T参数才能获得完整时间
const ADetails: boolean = true);
var
LDest: TStringStream;
begin
LDest := TStringStream.Create('');
try
if ADetails then
begin
InternalGet(trim('list -T ' + ASpecifier), LDest);
end
else
begin
InternalGet(trim('nlst ' + ASpecifier), LDest);
end;
ADest.Text := LDest.DataString;
finally LDest.Free;
end;
end;但改完了,Build All Project ,运行的结果与原来一模一样,是怎么回事啊?
但首先要去除Install Package的Indy选项,才能继续的具体看相关书本了==
就是上边那段
但可以不做改变的不改变的话,调用改为List(ADest,'-T');效果一样我用的Indy是自己改的版本故和实际的有所出入==
还有关键的是FTP服务器要支持Lits -T方法,目前有Serv-U,RDFTPD等
但IIS之类的是不支持的
---------------------------------------------------------------------
而不像“NMFTP1->FTPDirectoryList->ModifDate->Strings[i]”可以取到“ModifDate”(虽然不完整),这样的一个长字符串要如何过滤出日期呀?好头疼,不会要写个函数根据空格来取日期部分的字符串吧??再说即使取出“Jun 21 09:02:39 2004”日期串也不能直接转换为 TDateTime 型啊?StrToDateTime("Jun 21 09:02:39 2004") ; //根本就不认这种字符串大侠,帮人帮到底吧! 解决马上结贴!!!
看IDFTP的Help了IdFTPList.pas就是解释列表的,但有点Bug了,自己修正去了
"无法定位程序输入点 @Idresourcestrings@_RSBindingAny 于动态链接库 Indy60.bpl 上。"我下载了两个 Indy9 的压缩包,indy9.zip、Indy_9_00_14_src.zip ,
indy9.zip 中的文件日期比另一个新一些,indy9.zip 直接解开后里面有 243 个源文件和 3 个文件夹"AZ Demos、Boxster、SyncObjs",直接点击"Fullc6.bat"链接源文件后在其上级目录中会生成一个"C6"目录,之后在 C++Builder6 环境中 Romove 原有 Indy 组件后 Add Packages ,选择"C6"目录中的"dclIndy60.bpl",确定后就出现了上面的错误!我错在哪里了呢?
如果不好彩的话,你就要修改代码了
TIdFTP, See Also
Container for a structured file and directory listing.
property DirectoryListing: TIdFTPListItems;
Description
DirectoryListing is a read-only TIdFTPList property that represents the container and parser for TIdFTPListItem instances created from the result values for the List or Status methods. DirectoryListing is always cleared prior to adding the values returned by List or Status.
DirectoryListing provides a structured means of accessing data about files and directories returned from the FTP LIST, NLST, or STAT commands. DirectoryListing can also be used to populate GUI controls that display the results of the FTP operation, like TTreeView.DirectoryListing can be used with the OnParseCustomListFormat event handler to allow parsing of FTP List formats not normally supported by TIdFTPList.DirectoryListing is initialized prior to use in List, or using the OnCreateFTPList event handler. DirectoryListing is freed in the Destroy method.自己去IndyProject.org下载Demo了,里面有FTP的例子的了例如
procedure TMainForm.DirectoryListBoxDblClick(Sender: TObject);
Var
Name{, Line}: String;
begin
if not IdFTP1.Connected then exit;
//Line := DirectoryListBox.Items[DirectoryListBox.ItemIndex];
Name := IdFTP1.DirectoryListing.Items[DirectoryListBox.ItemIndex].FileName;
if IdFTP1.DirectoryListing.Items[DirectoryListBox.ItemIndex].ItemType = ditDirectory then begin
// Change directory
SetFunctionButtons(false);
ChageDir(Name);
SetFunctionButtons(true);
end
else begin
try
SaveDialog1.FileName := Name;
if SaveDialog1.Execute then begin
SetFunctionButtons(false); IdFTP1.TransferType := ftBinary;
BytesToTransfer := IdFTP1.Size(Name); if FileExists(Name) then begin
case MessageDlg('File aready exists. Do you want to resume the download operation?',
mtConfirmation, mbYesNoCancel, 0) of
mrYes: begin
BytesToTransfer := BytesToTransfer - FileSizeByName(Name);
IdFTP1.Get(Name, SaveDialog1.FileName, false, true);
end;
mrNo: begin
IdFTP1.Get(Name, SaveDialog1.FileName, true);
end;
mrCancel: begin
exit;
end;
end;
end
else begin
IdFTP1.Get(Name, SaveDialog1.FileName, false);
end;
end;
finally
SetFunctionButtons(true);
end;
end;
end;
IdFTP1->DirectoryListing 打出来就报错,好象根本没有这个方法!别人是怎么用的呢??奇怪···