EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Check directory exists (TElSimpleFTPSClient)

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#15156
Posted: 11/30/2010 02:53:24
by Diederik van Peer (Standard support level)
Joined: 09/09/2010
Posts: 2

Hi,

I am using TElSimpleFTPSClient to upload files to a remote folder via FTP. I need to verify if a remote (sub)directory exists before I call the Send method. How do I do this? I searched the Forums and documentation but cannot find a good way to check this.

Thanks for any suggestions.

Diederik
#15158
Posted: 11/30/2010 03:00:45
by Eugene Mayevski (EldoS Corp.)

You can CWD to this directory and check the result code.


Sincerely yours
Eugene Mayevski
#15162
Posted: 11/30/2010 04:34:58
by Diederik van Peer (Standard support level)
Joined: 09/09/2010
Posts: 2

Hi,

What do you mean exactly with 'the result code'?

Do you mean like this:

Code
TElSimpleFTPSClient client = Connect();

try
{
  client.MakeDir("parts");
}
catch (Exception e)
{
   //do nothing
}


Thanks.

Diederik
#15163
Posted: 11/30/2010 04:52:20
by Ken Ivanov (EldoS Corp.)

Almost. Use the CWD() method, not the MakeDir() one.
#15164
Posted: 11/30/2010 04:57:38
by Vsevolod Ievgiienko (EldoS Corp.)

Hello.

You can check if directory exists using this code:

Code
byte[] dirHandle;

try
{
  dirHandle = client.OpenDirectory(Directory_Path);
}
catch (EElSFTPError e)
{
  if (e.ErrorCode == SSH_ERROR_NO_SUCH_PATH) {
    // directory does not exists
  }
}

Client.CloseHandle(dirHandle);



P.S. I'm sorry. Please ignore this message because I mixed up SFTP and FTPS.
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

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