在MFC中写了个线程,用来传输文件的。
  
UINT ThreadFunc(LPVOID lpParam)
{ threadInfo* pInfo=(threadInfo*)lpParam; CFTPUploaderApp *app = (CFTPUploaderApp *)AfxGetApp();
app->IsThreadRunning=true;
CString sFileName;
int returnNum;
char *userName = new char[50];
memset(userName,NULL,50);
memcpy(userName,app->user,strlen(app->user));

FtpClient* client = new FtpClient("172.28.16.147",21); client->setCommand("USER ",userName);
client->sendCommand();
returnNum = client->receiveCommand();
if(returnNum == 331)
{
client->setCommand("PASS ",app->inputpassword.GetBuffer());
client->sendCommand();
returnNum = client->receiveCommand(); if(returnNum == 230)
{
char* filename = new char[512];
memset(filename,NULL,512); client->setCommand("PASV");
client->sendCommand();
client->receiveCommand();
client->getPort();
client->setCommand("TYPE ","I");
client->sendCommand();
client->receiveCommand();
client->interlizeDataSocket();

//----------循环遍历list.dat文件上传开始----------// while(true)
{
CString tmp,first;
CStdioFile file("list.dat",CFile::modeReadWrite);
file.ReadString(tmp);
if(tmp=="")
break;
first=tmp;
CString str="";
while(file.ReadString(tmp)&&tmp!="")
{
str+=tmp;
}
file.SetLength(0);
file.WriteString(str);
file.Close();
char fileName[100]="",url[100]="",size[10]="";
sscanf(first,"%s %s %s",fileName,url,size);
if((LONGLONG)size!=0)
{
client->setCommand("REST",size);
client->sendCommand();
client->receiveCommand();
} client->setCommand("STOR ",UTF8Convert(fileName,936,CP_UTF8).GetBuffer());
client->sendCommand();
client->receiveCommand();
client->sendData(url,pInfo->pctrlProgress,(LONGLONG)size);
client->receiveCommand();  //想在此处执行完再进行下一次的循环,可是现实是程序还没执行完这个函数就开始下一个循环了,何解??? }
//----------循环遍历list.dat文件上传结束----------//
}
}
app->IsThreadRunning=false;
return 1;
}