EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Change directory for Write

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#4022
Posted: 10/15/2007 16:22:08
by Leslie Andrews (Basic support level)
Joined: 10/15/2007
Posts: 2

I searched the forum and found that the OpenDirectory command that I am using is only valid for changing a directory on the server to read. I need to be able to change the directory on the server to WRITE a file in my Delphi 6 program...When I was using the Indy components I could use the ChangeDir command, but I can't seem to find the equivalent in the TElSimpleSFTPClient component. Am I required to use the ElSFTPClient to change to another directory on the server for Writing?

Thank you.

Leslie Andrews

#4023
Posted: 10/15/2007 23:53:01
by Eugene Mayevski (EldoS Corp.)

What is "change directory"? If you are talking about FTP's CWD command, then SFTP doesn't have it, as it doesn't have a concept of current directory. Please read the FAQ in SecureBlackbox knowledgebase.


Sincerely yours
Eugene Mayevski
#4034
Posted: 10/16/2007 08:11:32
by Leslie Andrews (Basic support level)
Joined: 10/15/2007
Posts: 2

Ok I read the FAQ, how do I set the absolute path?

Currently I am doing this:
Code
procedure TfrmMain.TransferPaymentFile1Click(Sender: TObject);
var
  strFileName, strTransferID : string;
  intLastTransferID : integer;
  Save_Cursor : TCursor;
  i : integer;
begin
  frmMain.OpenDialog1.InitialDir:= ExtractFilePath(Application.ExeName) + '\FileTransfer';
  if frmMain.OpenDialog1.Execute then
  begin
    try
      Save_Cursor := Screen.Cursor;
      Screen.Cursor := crHourGlass;
      PasswordDlg.ShowModal;
      if PasswordDlg.ModalResult = mrOk then
      begin
        FTP_SHARE.Open;
        if FTP_SHARE.Active then
        begin
          try
            try
              For i := 0 to OpenDialog1.Files.Count - 1 do
              begin
                FTP_SHARE.UploadFile(OpenDialog1.Files.Strings[i], ExtractFileName(OpenDialog1.Files.Strings[i]));
              end;
            finally
              ShowMessage('Files successfully transfered!');
            end;
          except
            on E : Exception do
            begin
              ShowMessage('Error during upload: ' + E.Message);
            end;
          end;
        end;
      end;
    finally
      Screen.Cursor := Save_Cursor;  // Always restore to normal
    end;
  end;
end;


When the user fills in the UserName on the login form, the server sets the path to the username: \AGENCY218

I need to transfer to the path:
\AGENCY218\IN\

Thanks.
Leslie
#4038
Posted: 10/16/2007 10:03:27
by Ken Ivanov (EldoS Corp.)

Quote
how do I set the absolute path?

The absolute path cannot be set. The absolute path is just the canonical value of some relative path. E.g., the "./dir1/dir2" path is relative path, and "/home/user1/dir1/dir2" is the corresponding absolute path. RequestAbsolutePath() simply obtains the absolute path for some relative path.

You can use the following algorithm to upload the file to the needed location:
1. As soon as SFTP session is opened, call RequestAbsolutePath(".") to get the absolute path value for the user home directory.

HomePath := Client.RequestAbsolutePath('.');

2. Form the destination path by appending the needed subdirectory name to the obtained home path string.

UploadPlace := HomePath + '/' + 'IN/';

Reply

Statistics

Topic viewed 2554 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!