Home > Back-end >  How IdFTPserver accept changedir request
How IdFTPserver accept changedir request

Time:10-22

When using IdFTP controls, I through changedir dynamic change IdFTPserver directory, IdFTPserver there should be how to operate? And Idserver there is how the reception?????? ,,,,,, please the great god guide ah,,,,

CodePudding user response:

Procedure TForm1. IdFTPServer1ChangeDirectory (ASender: TIdFTPServerThread;
Var VDirectory: String);
Adjust directory for the higher level directory * {*}
The Function EraseLastString (Source: String; EraseChar: Char) : String;
Var
BasePoint DymaPoint: integer;
StrLen: Integer;
The begin
StrLen:=Length (Source);
If StrLen<=0 then
Result:=Source;
//is the root directory
DymaPoint:=1;
//initialize the pointer
For BasePoint:=1 to StrLen do
The begin
If the Source [BasePoint]=EraseChar then
DymaPoint:=BasePoint;
//location directory separator characters
end;
If DymaPoint=1 then
The begin
Result:=EraseChar
End
The else
The begin
SetLength (Source, DymaPoint - 1);
Result:=Source;
end;
end;

Var
CurrentDir: String;
The begin
CurrentDir:=ASender. CurrentDir;
{} to determine whether the current directory to the root directory
If VDirectory='.. \ 'then
The begin
VDirectory:=EraseLastString (CurrentDir, '\');
end;

end;

CodePudding user response:

This is my time in the upload file to determine which folder on the server code
Procedure TFServer. IdFTPServer1StoreFile (ASender: TIdFTPServerThread;
Const AFileName: String; AAppend: Boolean; Var VStream: TStream);
Var
NewFile: String;
The begin
//will be used in the FTP directory of symbol "/" into Windows directory symbol ""
NewFile:=ChangeFolderChar (WorkDirectory. Text + AFileName);
//set up a corresponding files in the FTP server, and specify the file access interface
VStream:=TFileStream. Create (NewFile, fmCreate);
end;

The Function ChangeFolderChar (Str: String) : String;
//will be used in the FTP directory symbol "/" into "" in the Windows directory signs function
Var
I: Integer;
Mystr: string;
The begin
For I:=0 to length (Str) - 1 do
The begin
If the Str [I]='/' then
Str: [I]='\';
end;
Result:=Str;
end;

Then perform newfile right after the normal is C: \ \ folder a.t xt here into C: \ \ \ \ folder a.t xt then error can't find the directory, you see if you can help me

CodePudding user response:


You use my try

CodePudding user response:

You this is I don't know how to embed in my application, I send you my program, you can help me to look at?
  • Related