procedure TUpLoadFrm.DoUploadInterrupDir(sDirName, sToDirName: String); var hFindFile:Cardinal; t,tfile,DirPath:String; sCurDir:String[255]; FindFileData:WIN32_FIND_DATA; StrValue:String; Info_temp :array[0..400] of char; begin DirPath:=''; StrValue:=''; sCurDir:=GetCurrentDir; ChDir(sDirName); hFindFile:=FindFirstFile('*.*',FindFileData); if hFindFile<>INVALID_HANDLE_VALUE then begin if not EnterDirectories(sToDirName) then begin if sToDirName<>'' then CreateDirectories(sToDirName); end; repeat tfile:=FindFileData.cFileName; if (tfile='.') or (tfile='..') then //假如是顶级目录中断找下一个。 Continue; if ((FindFileData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) =FILE_ATTRIBUTE_DIRECTORY) then //是否是文件目录 begin t:=sToDirName+'/'+tfile; //给出其路径进入文件遍历的递归。 if sDirName[Length(sDirName)]<>'\' then DoUploadInterrupDir(sDirName+'\'+tfile,t) else DoUploadInterrupDir(sDirName+tfile,sToDirName+tfile); end else begin if sDirName[length(sDirName)]<>'\' then t:=sDirName+'\'+tFile //取文件的路径 开始出栈。 else t:=sDirName+tFile; try if (tFile=LocsearchFile) then IsUpLoad:=TRUE; if ( IsUpLoad) and (tFile<>LocsearchFile) then begin // CompressUploadFile(t,t,100); // idftp1.Put( t+'.TMP.~!#',sToDirName+'/'+tFile+'.TMP.~!#'); CurrStausInI.WriteString(GloablFileName,'上传文件',t); // deletefile(t+'.TMP.~!#'); idftp1.Put(t,sToDirName+'/'+tFile); DirPath:=copy(sToDirName,dirLen+2,length(StoDirName)-DirLen); if Length(DirPath)>0 then Strvalue:=DirPath+'/'+tFile+':'+inttostr((FindFileData.nFileSizeHigh * MAXDWORD)+FindFileData.nFileSizeLow)+':'+intToStr(fileAge(t))+':0'+#13+#10 //回车换行 else Strvalue:=tFile+':'+inttostr((FindFileData.nFileSizeHigh * MAXDWORD)+ FindFileData.nFileSizeLow)+':'+intToStr(fileAge(t))+':0'+#13+#10; StrlCopy(info_temp,Pchar(StrValue),400); TempFile.Write(info_temp,Length(Strvalue)); //写TXT文件 end; except ShowMessage(t+' '+sToDirName+'/'+tFile); ShowMessage('Upload File Error'); end; end; until FindNextFile(hFindFile,FindFileData)=false; end else begin ChDir(sCurDir); exit; end; //回到原来的目录下 ChDir(sCurDir); end; 每次传到{5AD72A1D-69E0-4A5B-96BB-83022861E9CF}.TDB 这个文件时都会抛异常
var
hFindFile:Cardinal;
t,tfile,DirPath:String;
sCurDir:String[255];
FindFileData:WIN32_FIND_DATA;
StrValue:String;
Info_temp :array[0..400] of char;
begin
DirPath:='';
StrValue:='';
sCurDir:=GetCurrentDir;
ChDir(sDirName);
hFindFile:=FindFirstFile('*.*',FindFileData);
if hFindFile<>INVALID_HANDLE_VALUE then
begin
if not EnterDirectories(sToDirName) then
begin
if sToDirName<>'' then
CreateDirectories(sToDirName);
end;
repeat
tfile:=FindFileData.cFileName;
if (tfile='.') or (tfile='..') then //假如是顶级目录中断找下一个。
Continue;
if ((FindFileData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) =FILE_ATTRIBUTE_DIRECTORY) then //是否是文件目录
begin
t:=sToDirName+'/'+tfile; //给出其路径进入文件遍历的递归。
if sDirName[Length(sDirName)]<>'\' then
DoUploadInterrupDir(sDirName+'\'+tfile,t)
else
DoUploadInterrupDir(sDirName+tfile,sToDirName+tfile);
end
else
begin
if sDirName[length(sDirName)]<>'\' then
t:=sDirName+'\'+tFile //取文件的路径 开始出栈。
else
t:=sDirName+tFile;
try
if (tFile=LocsearchFile) then IsUpLoad:=TRUE;
if ( IsUpLoad) and (tFile<>LocsearchFile) then
begin
// CompressUploadFile(t,t,100);
// idftp1.Put( t+'.TMP.~!#',sToDirName+'/'+tFile+'.TMP.~!#');
CurrStausInI.WriteString(GloablFileName,'上传文件',t);
// deletefile(t+'.TMP.~!#');
idftp1.Put(t,sToDirName+'/'+tFile);
DirPath:=copy(sToDirName,dirLen+2,length(StoDirName)-DirLen);
if Length(DirPath)>0 then
Strvalue:=DirPath+'/'+tFile+':'+inttostr((FindFileData.nFileSizeHigh * MAXDWORD)+FindFileData.nFileSizeLow)+':'+intToStr(fileAge(t))+':0'+#13+#10 //回车换行
else
Strvalue:=tFile+':'+inttostr((FindFileData.nFileSizeHigh * MAXDWORD)+ FindFileData.nFileSizeLow)+':'+intToStr(fileAge(t))+':0'+#13+#10;
StrlCopy(info_temp,Pchar(StrValue),400);
TempFile.Write(info_temp,Length(Strvalue)); //写TXT文件
end;
except
ShowMessage(t+' '+sToDirName+'/'+tFile);
ShowMessage('Upload File Error');
end;
end;
until FindNextFile(hFindFile,FindFileData)=false;
end
else
begin
ChDir(sCurDir);
exit;
end;
//回到原来的目录下
ChDir(sCurDir);
end;
每次传到{5AD72A1D-69E0-4A5B-96BB-83022861E9CF}.TDB 这个文件时都会抛异常