整个目录下的文件上传问题解决方法(100分)

B

bjf2001

Unregistered / Unconfirmed
GUEST, unregistred user!
我用如下的代码实现整个目录下的文件上传到远程服务器出现错误:
function TForm1.DoUploadDir(sDirName:String;sToDirName:String):Boolean; //上传主函数
var
hFindFile:Cardinal;
t,tfile:String;
sCurDir:String[255];
FindFileData:WIN32_FIND_DATA;
begin
//先保存当前目录
sCurDir:=GetCurrentDir;
ChDir(sDirName);
hFindFile:=FindFirstFile('*.*',FindFileData);
if hFindFile<>INVALID_HANDLE_VALUE then
begin
if not DirectoryExists(sToDirName) then
begin
if(sToDirName<>'') then
IdFTP1.MakeDir(sToDirName); //这句makedir为什么不能用?
end;
repeat
tfile:=FindFileData.cFileName;
if (tfile='.') or (tfile='..') then
Continue;
if FindFileData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY then //此句是什么意思,我的上传在本机上测试没有错误,在网络上出现错误。
begin
t:=sToDirName+'/'+tfile;
// showmessage(sDirName+'/'+tfile+','+t);
// if not DirectoryExists(t) then
// NMFTP1.MakeDirectory(t);
if sDirName[Length(sDirName)]<>'/' then
DoUploadDir(sDirName+'/'+tfile,t)
else
DoUploadDir(sDirName+tfile,sToDirName+tfile);
end
else
begin
t:=sToDirName+'/'+tFile;
try
{ NMFTP1.Mode(MODE_BYTE);
AssignFile(F, tfile);
Reset(F);
FSize := FileSize(F);
CloseFile(F);
NMFTP1.Allocate(FSize);
}
IdFTP1.Put(tfile, t);
except end;
end
until FindNextFile(hFindFile,FindFileData)=false;
// FindClose(hFindFile);
end
else
begin
ChDir(sCurDir);
result:=false;
exit;
end;
//回到原来的目录下
ChDir(sCurDir);
result:=true;
end;

整个的问题都在上面打问号上。谢谢大家解决!急等
 
大家帮帮忙呀。
 
我不懂,来听课~ ^o^
 
兄弟门,快点来呀!
 
我给你发代码,请收好!马上给分呀
 
接受答案了.
 
顶部