如何快速提取指定ftp服务下指定文件的大小(50分)

  • 主题发起人 主题发起人 Cjzhou
  • 开始时间 开始时间
怎么没人回答
 
找一控件就拉倒了
如:ICS
 
你用控件idftp就可以,如下:
function Size(const AFileName: String): Integer;
Parameters
const AFileName: String:The file name
Returns:Integer - Size of the file or -1 when unknown.


Description

Size is an Integer function used to retrieve file size information for the file specified in AFilename from the FTP server.
 
现在使用的是nmftp,谁有办法解决?
 
uses WinInet;
function GetfileSize(Host:PChar;UserID:PChar;Password:PChar;FileName:PChar):longint;
function GetfileSize(Host:PChar;UserID:PChar;Password:PChar;FileName:PChar):longint;
var
FindData: TWin32FindData;
FindHandle: HInternet;
FINet: HInternet;
FFtpHandle: HInternet;
FileSize:LongInt;
begin
FileSize:=0;
finet:=internetopen('main',0,nil,0,0);
FftpHandle := InternetConnect(FINet, Host, 0,
UserID, Password,
Internet_Service_Ftp, 0, 255);
if FFtpHandle = nil then
FileSize:=0
else
begin
FindHandle := FtpFindFirstFile(FFtphandle, pchar('/'+FileName),
FindData, 0, 0);
if FindHandle=nil then
begin
FindHandle := FtpFindFirstFile(FFtphandle, pchar('/Backup/'+FileName),
FindData, 0, 0);
if FindHandle=nil then
FileSize :=0
else
FileSize :=FindData.nFileSizeHigh*255+FindData.nFileSizeLow;
end
else
begin
FileSize :=FindData.nFileSizeHigh*255+FindData.nFileSizeLow;
end;
end;
InternetCloseHandle(finet);
result :=FileSize;
end;
 
接受答案了.
 
后退
顶部