我在做一个FTP管理端的时候程序启动时最小化到任务栏,当点击任务栏图标时弹出式菜单半天才有反应,原因是上传一个比较大的文件(可能会有100M),我也在程序里用了消息处理的方法却不行,请高手指点。代码如下。Procedure TUpLoadFrm.DoUploadDir(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
UploadInfoFrm.memo1.Lines.Append('进入上传函数 doUpLoadDir:');
DirPath:='';
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
Application.ProcessMessages;*********此处在处理消息
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
DoUploadDir(sDirName+'\'+tfile,t)
else
DoUploadDir(sDirName+tfile,sToDirName+tfile);
end
else
begin
if sDirName[length(sDirName)]<>'\' then
t:=sDirName+'\'+tFile //取文件的路径 开始出栈。
else
t:=sDirName+tFile;
try
if fileExists(t+'.TMP.~!#') thenUploadInfoFrm.memo1.Lines.Append('正在上传文件--->'+DirPath+'/'+tFile);
NetStatusTimer.Enabled:=TRUE;
CheckNetStatus:=FALSE;
idftp1.Put(t,sToDirName+'/'+tFile);
UploadInfoFrm.memo1.Lines.Append('CheckNetStatus='+boolToStr(CheckNetStatus));
UploadInfoFrm.memo1.Lines.Append('正在记录当前所传的文件记录--->UpLoadStatus.ini');
CurrStausInI.WriteString(GloablFileName,'上传文件',t);
DirPath:=copy(sToDirName,dirLen+2,length(StoDirName)-DirLen);
StrValue:='';
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;
if inttostr((FindFileData.nFileSizeHigh * MAXDWORD)+FindFileData.nFileSizeLow)<>'0'then
begin
UploadInfoFrm.memo1.Lines.Append('正在写文件记录--->'+tFile);
StrlCopy(info_temp,Pchar(StrValue),400);
TempFile.Write(info_temp,Length(Strvalue)); //写TXT文件
UploadInfoFrm.memo1.Lines.Append('写文件记录 结束');
end;
except
CheckNetStatus:=TRUE;
UploadInfoFrm.memo1.Lines.Append('上传文件: '+DirPath+'/'+tFile+' 异常');
// ShowMessage(t+' zzzz '+sToDirName+'/'+tFile);
// ShowMessage('DoUploadDir');
end;
end;
until FindNextFile(hFindFile,FindFileData)=false;
end
else
begin
ChDir(sCurDir);
exit;
end;
//回到原来的目录下
ChDir(sCurDir);
end;
var
hFindFile:Cardinal;
t,tfile,DirPath:String;
sCurDir:String[255];
FindFileData:WIN32_FIND_DATA;
StrValue:String;
Info_temp :array[0..400] of char;
begin
UploadInfoFrm.memo1.Lines.Append('进入上传函数 doUpLoadDir:');
DirPath:='';
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
Application.ProcessMessages;*********此处在处理消息
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
DoUploadDir(sDirName+'\'+tfile,t)
else
DoUploadDir(sDirName+tfile,sToDirName+tfile);
end
else
begin
if sDirName[length(sDirName)]<>'\' then
t:=sDirName+'\'+tFile //取文件的路径 开始出栈。
else
t:=sDirName+tFile;
try
if fileExists(t+'.TMP.~!#') thenUploadInfoFrm.memo1.Lines.Append('正在上传文件--->'+DirPath+'/'+tFile);
NetStatusTimer.Enabled:=TRUE;
CheckNetStatus:=FALSE;
idftp1.Put(t,sToDirName+'/'+tFile);
UploadInfoFrm.memo1.Lines.Append('CheckNetStatus='+boolToStr(CheckNetStatus));
UploadInfoFrm.memo1.Lines.Append('正在记录当前所传的文件记录--->UpLoadStatus.ini');
CurrStausInI.WriteString(GloablFileName,'上传文件',t);
DirPath:=copy(sToDirName,dirLen+2,length(StoDirName)-DirLen);
StrValue:='';
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;
if inttostr((FindFileData.nFileSizeHigh * MAXDWORD)+FindFileData.nFileSizeLow)<>'0'then
begin
UploadInfoFrm.memo1.Lines.Append('正在写文件记录--->'+tFile);
StrlCopy(info_temp,Pchar(StrValue),400);
TempFile.Write(info_temp,Length(Strvalue)); //写TXT文件
UploadInfoFrm.memo1.Lines.Append('写文件记录 结束');
end;
except
CheckNetStatus:=TRUE;
UploadInfoFrm.memo1.Lines.Append('上传文件: '+DirPath+'/'+tFile+' 异常');
// ShowMessage(t+' zzzz '+sToDirName+'/'+tFile);
// ShowMessage('DoUploadDir');
end;
end;
until FindNextFile(hFindFile,FindFileData)=false;
end
else
begin
ChDir(sCurDir);
exit;
end;
//回到原来的目录下
ChDir(sCurDir);
end;
解决方案 »
- delphi中有日期控件吗?
- 请问如何编ping一段网络地址的?
- 100求《Delphi5.XADO_MTS_COM+高级程序设计篇》 附书光盘;
- 有谁收集了各种各样的图标吗(.ico&.bmp32*32,16*16,64*64)?高分相赠!提供网址也可以!
- 笨笨的问题:菜单设计时如何创建一个分割线?
- 组件服务中的Application应用程序在系统管理组件时起什么作用
- 有人要招聘delphi程序员吗?请进来一看啊!
- 如何判断AdoDataSet1.BeforeDelete是否已赋值?
- 请问如何打开.res文件,从而获得文件里的图标。
- 一个关于index排序的问题?答完立即给分
- dbexpress连接mysql的问题
- 请问为什么运行程序的时候总是弹出那个数据库登录窗口?我用的是data module
逻辑问题?使用的上传组件问题?认真检查去了LYFTP at
http://lysoft.7u7.net