idftp,如何做ftp上传进度条?

chiengod 2007-06-10 06:23:36
如题!
...全文
848 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
brightyang 2007-06-12
  • 打赏
  • 举报
回复
double AverageSpeed;
int FileLenCurrentCount;

void __fastcall TForm1::IdFTP1Work(TObject *Sender, TWorkMode AWorkMode,
const int AWorkCount)
{
AnsiString s;
TDateTime TotalTime;
WORD H, M, Sec, MS;
double DLTime;

TotalTime = Now() - STime;
DecodeTime(TotalTime, H, M, Sec, MS);
Sec = Sec + M * 60 + H * 3600;
DLTime = Sec + MS / 1000;
FileLenCurrentCount=AWorkCount/1024;
if (DLTime > 0)
AverageSpeed = (AverageSpeed + (AWorkCount / 1024) / DLTime) / 2;

s = FormatFloat("0.00 KB/s", AverageSpeed);

switch (AWorkMode)
{ case wmRead:
{ Label2->Caption = "下载速度 " + s;
if(FileLenCurrentCount>0)
Label3->Caption ="下载 "+IntToStr(FileLenCurrentCount)+" KB 总计 "+IntToStr(FileLenCount)+" KB";
break;
}
case wmWrite:
{
Label2->Caption = "上传速度 " + s;
if(FileLenCurrentCount>0)
Label3->Caption="上传 "+IntToStr(FileLenCurrentCount)+" KB 总计 "+IntToStr(FileLenCount)+" KB";
}
};

if (AbortTransfer)
IdFTP1->Abort();

ProgressBar1->Position = AWorkCount;
AbortTransfer = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdFTP1WorkBegin(TObject *Sender,
TWorkMode AWorkMode, const int AWorkCountMax)
{
STime = Now();
if (AWorkCountMax > 0)
{
ProgressBar1->Max = AWorkCountMax;

}
else
{
ProgressBar1->Max = BytesToTransfer;
}
AverageSpeed = 0;
FileLenCount=AWorkCountMax/1024;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdFTP1WorkEnd(TObject *Sender, TWorkMode AWorkMode)
{
BytesToTransfer = 0;
ProgressBar1->Position = 0;
AverageSpeed = 0;
FileLenCount=0;
FileLenCurrentCount=0;

}
chiengod 2007-06-12
  • 打赏
  • 举报
回复
能否给点相关代码呀.
dabaicai 2007-06-11
  • 打赏
  • 举报
回复
用线程上传,对应事件,再同步界面就可以了
hongqi162 2007-06-10
  • 打赏
  • 举报
回复
参考
http://topic.csdn.net/t/20051229/20/4489481.html

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧