Jag kan ikke få TIdTrivialFTPServer til at virke i CBuilder (XP)
Jeg sidder og leger med Indy's TidTrivialFTPServer og IdTrivialFTP component. Jeg fandt et lille eksempel på nettet skrevet i Delphi som jeg har taget udgangspunkt i. Men det virker ikke.Jeg har to knapper på min form, som sætter Server og Client componenten aktiv.
1. Jeg starter TidTrivialFTPServer op (Active=true)
2. Jeg starter TidTrivialFTP op (Active=true).
men der sker ikke noget over på Server delen (IdTrivialFTP1Status)
Er der nogen der kan fortælle mig hvad jeg gør forkert ?
AnsiString TFTPPath = "C:\\TEMP";
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTrivialFTPServer1Status(TObject *axSender,
const TIdStatus axStatus, const AnsiString asStatusText)
{
Memo1->Lines->Add("Test");
Memo1->Lines->Add(asStatusText);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTrivialFTP1Status(TObject *axSender,
const TIdStatus axStatus, const AnsiString asStatusText)
{
Memo2->Lines->Add(asStatusText);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
IdTrivialFTPServer1->Active=true;
IdTrivialFTPServer1->ThreadedEvent = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
IdTrivialFTP1->Host = "127.0.0.1";
IdTrivialFTP1->Active=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
TMemoryStream *ST;
int I;
AnsiString S;
ST = new TMemoryStream();
S = "This is a test file. It whould appear in the TFTP Server''s upload directory.";
ST->Write(&S,S.Length());
ST->Position = 0;
IdTrivialFTP1->Put(ST,"textfile.txt");
delete ST;
Memo2->Lines->Add("Done!");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTrivialFTPServer1ReadFile(TObject *Sender,
AnsiString &FileName, const TPeerInfo &PeerInfo, bool &GrantAccess,
TStream *&AStream, bool &FreeStreamOnComplete)
{
TFileStream *FS;
FreeStreamOnComplete = true;
FileName = ExtractFileName( FileName );
// Check if file exists
if (FileExists( TFTPPath+FileName ))
{
// Open file in READ ONLY mode
FS = new TFileStream(TFTPPath+FileName,fmOpenRead | fmShareDenyWrite);
// Assign stream to variable }
AStream = FS;
// Set parameters
GrantAccess = True;
}
else
{
GrantAccess = True;
}
Memo1->Lines->Add("ReadFile");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTrivialFTPServer1TransferComplete(
TObject *Sender, const bool Success, const TPeerInfo &PeerInfo,
TStream *AStream, const bool WriteOperation)
{
Memo1->Lines->Add("TransferComplete");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTrivialFTPServer1UDPRead(TObject *Sender,
TStream *AData, TIdSocketHandle *ABinding)
{
Memo1->Lines->Add("UDPRead");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IdTrivialFTPServer1WriteFile(TObject *Sender,
AnsiString &FileName, const TPeerInfo &PeerInfo, bool &GrantAccess,
TStream *&AStream, bool &FreeStreamOnComplete)
{
Memo1->Lines->Add("WriteFile");
}