Xbase++
Xbase++
SFTP Create Directory
See more SFTP Examples
Demonstrates how to create a new directory on the remote SFTP server.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oSftp
nSuccess := 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.
oSftp := CreateObject("Chilkat.SFtp")
// Set some timeouts, in milliseconds:
oSftp:ConnectTimeoutMs := 15000
oSftp:IdleTimeoutMs := 15000
// Connect to the SSH server.
nSuccess := oSftp:Connect("sftp.example.com", 22)
IF (nSuccess != 1)
? oSftp:LastErrorText
oSftp:destroy()
RETURN
ENDIF
// Authenticate with the SSH server. Chilkat SFTP supports
// both password-based authenication as well as public-key
// authentication. This example uses password authenication.
nSuccess := oSftp:AuthenticatePw("myLogin", "myPassword")
IF (nSuccess != 1)
? oSftp:LastErrorText
oSftp:destroy()
RETURN
ENDIF
// After authenticating, the SFTP subsystem must be initialized:
nSuccess := oSftp:InitializeSftp()
IF (nSuccess != 1)
? oSftp:LastErrorText
oSftp:destroy()
RETURN
ENDIF
// Create a new directory:
nSuccess := oSftp:CreateDir("myNewDir")
IF (nSuccess != 1)
? oSftp:LastErrorText
oSftp:destroy()
RETURN
ENDIF
? "Success."
oSftp:destroy()