Sample code for 30+ languages & platforms
Visual FoxPro

SFTP Create Directory

See more SFTP Examples

Demonstrates how to create a new directory on the remote SFTP server.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loSftp

lnSuccess = 0

*  This example assumes the Chilkat API to have been previously unlocked.
*  See Global Unlock Sample for sample code.

*  Important: It is helpful to send the contents of the
*  sftp.LastErrorText property when requesting support.

loSftp = CreateObject('Chilkat.SFtp')

*  Set some timeouts, in milliseconds:
loSftp.ConnectTimeoutMs = 15000
loSftp.IdleTimeoutMs = 15000

*  Connect to the SSH server.  
lnSuccess = loSftp.Connect("sftp.example.com",22)
IF (lnSuccess <> 1) THEN
    ? loSftp.LastErrorText
    RELEASE loSftp
    CANCEL
ENDIF

*  Authenticate with the SSH server.  Chilkat SFTP supports
*  both password-based authenication as well as public-key
*  authentication.  This example uses password authenication.
lnSuccess = loSftp.AuthenticatePw("myLogin","myPassword")
IF (lnSuccess <> 1) THEN
    ? loSftp.LastErrorText
    RELEASE loSftp
    CANCEL
ENDIF

*  After authenticating, the SFTP subsystem must be initialized:
lnSuccess = loSftp.InitializeSftp()
IF (lnSuccess <> 1) THEN
    ? loSftp.LastErrorText
    RELEASE loSftp
    CANCEL
ENDIF

*  Create a new directory:
lnSuccess = loSftp.CreateDir("myNewDir")
IF (lnSuccess <> 1) THEN
    ? loSftp.LastErrorText
    RELEASE loSftp
    CANCEL
ENDIF

? "Success."

RELEASE loSftp