EldoS | Feel safer!

Software components for data protection, secure storage and transfer

DirectoryListbox with SFTPClient.ListDirectory

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#15082
Posted: 11/17/2010 14:49:26
by Doug Haskins (Basic support level)
Joined: 02/11/2010
Posts: 1

I am working on an inhouse SFTP program. It is using Delphi's DirectoryListbox to display the local file directory, and i'm trying to use the same component to display the remote file directory.

Using SFTPCLient i can connect to the site and collect the directory listing into a TList using OpenDirectory and ListDirectory, but not sure how to get that info into DirectoryListbox, or if there is a better way to do this?

Anyone have an idea on how to link these two components up, or if you have created an SFTP program, how did you display the remote directory listing?

Thanks.

Here is my code so far. It displays the remote directory contents into a memo;

//Set the LocalDirectoryListbox to the local directory
ForceDirectories('c:\SDXSCommandCenterTemp\SFTPFiles\'+ConnectionCombobox.Text);
LocalDirectoryListbox.Directory := 'c:\SDXSCommandCenterTemp\SFTPFiles\'+ConnectionCombobox.Text;

//Get the current directory from the site
dirList := TList.Create;

SftpClient.OpenDirectory(directoryname);
SftpClient.ListDirectory(directoryname, dirList);

for cnt := 0 to dirList.Count - 1 do
begin
SFTPConnectionMemo.Lines.Add(ElSftpFileInfo(DirList[cnt]).Name);
end;
dirList.Free;
#15085
Posted: 11/17/2010 23:51:26
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

You should better use TTreeView component to display remote directory contents.

Code
var
  tn : TTreeNode;
  ...
begin
    tn := TreeView1.Items.Add(nil, 'Root');

    for cnt := 0 to dirList.Count - 1 do
    begin
      TreeView1.Items.AddChild(tn, ElSftpFileInfo(DirList[cnt]).Name);
    end;
end;

Reply

Statistics

Topic viewed 2122 times

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




|

Back to top

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

Got it!