I am transferring files over LAN using Tidtrivialftpserver and Tidtrivialftp. I tried the example code and is working fine but Tidtrivialftpserver just starts writing file ,i want to implement a savedialog box so that i can save it on my desired location.i tried following but it writes file in the current directory. Also i am not convinced with this line (AStream := FS) in serverWriteFile because when i debug this code Astream gives nil but still it writes file. How?
var
file1: string;
FS: tfilestream;
procedure TForm2.saveClick(Sender: TObject);
begin
if savedialog1.Execute then
begin
savedialog1.FileName:= file1;
FS := TFileStream.Create(FileName,
fmCreate or fmShareExclusive);
end;
end;
procedure TForm2.serverWriteFile(Sender: TObject; var FileName: string;
const PeerInfo: TPeerInfo; var GrantAccess: Boolean; var AStream: TStream;
var FreeStreamOnComplete: Boolean);
begin
try
Memo1.Lines.Add('started writing files...');
file1 := ExtractFileName(Filename);
{ Open file in WRITE ONLY mode }
// FS := TFileStream.Create(FileName,
// fmCreate or fmShareExclusive);
{ Copy all the data }
AStream := FS;
{ Set parameters }
FreeStreamOnComplete := True;
GrantAccess := True;
except
{ On errors, deny access }
GrantAccess := False;
if Assigned(FS) then
FreeAndNil(FS);
end;
end;