Пересылка файлов Indy
Вот ссылка:
http://forum.vr-online.ru/index.php?act=Print&client=printer&f=2&t=612
My email: [email]vmyletterbox@yandex.ru[/email]
На сервере:
void __fastcall TForm1::IdTCPServer1Execute(TIdPeerThread *AThread)
{
AnsiString C_Path = "C:\\1\\" + ExtractFileName(AThread->Connection->ReadLn());
int hnd;
if(!FileExists(C_Path))
{
hnd=FileCreate(C_Path);
if(hnd==-1)
{
Application->MessageBox("Не удалось...",C_Path.c_str(),MB_ICONEXCLAMATION);
return;
}
FileClose(hnd);
}
TFileStream *f = new TFileStream(C_Path,fmOpenWrite);
AThread->Connection->ReadStream(f,-1,true);
Sleep(5000);
delete f;
}
На клиенте:
void __fastcall TForm1::Button4Click(TObject *Sender)
{
if(OpenDialog1->Execute()){
IdTCPClient1->Connect();
IdTCPClient1->WriteLn(OpenDialog1->FileName);
TFileStream *f = new TFileStream(OpenDialog1->FileName,fmOpenRead);
IdTCPClient1->OpenWriteBuffer();
IdTCPClient1->WriteStream(f,true,true);
IdTCPClient1->CloseWriteBuffer();
delete f;
IdTCPClient1->Disconnect();
}
}
Остался вопрос – все нормально со всеми файлами кроме видео файлов, они перестают открываться после пересылки. Хотя размеры отправленного и принятого совпадают. Может, кто знает, как исправить?