EldoS | Feel safer!

Software components for data protection, secure storage and transfer

ReadDirectory under Delphi

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#3670
Posted: 09/01/2007 04:20:09
by Thomas Hartmann (Basic support level)
Joined: 09/01/2007
Posts: 1

Does anyone have an example of implementation of ReadDirectory() under Delphi / Pascal

I tried to read the filenames from a server with, OpenDirectory ==> ReadDirectory, but I am not able to read the Filenames with ElSftpFileInfo.Name.
#3671
Posted: 09/01/2007 04:29:02
by Santiago CastaƱo (Standard support level)
Joined: 04/16/2006
Posts: 155

You can look at SimpleSFTP Sample (you simply need to feed it a TList object that will hold TElSftpFileInfo objects)

Code
    dirHandle := SftpClient.OpenDirectory(StrFromANSI(FCurrentDir));
    dirList := TList.Create;
    try
      SftpClient.ReadDirectory(dirHandle, dirList);

      for I := 0 to dirList.Count - 1 do
      begin
        TElSftpFileInfo(dirList.Items[I]).Name := StrToANSI(TElSftpFileInfo(dirList.Items[I]).Name);
        TElSftpFileInfo(dirList.Items[I]).LongName := StrToANSI(TElSftpFileInfo(dirList.Items[I]).LongName);
      end;

      for I := 0 to dirList.Count - 1 do
      begin
//you have the names in TElSftpFileInfo(dirList.Items[I]).Name
        // the returned ElSftpFileInfo object must be freed by the application
        TElSftpFileInfo(dirList.Items[I]).Free;
      end;
    finally
      dirList.Free;
      SftpClient.CloseHandle(dirHandle);
    end;

Reply

Statistics

Topic viewed 2666 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!