And in help file it say _FTP_DirGetCurrent( $hFTPSession ) is command to get all data from current session, in my case $FTPopen
Code:
#RequireAdmin
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <GUIListView.au3>
#include <FTPEx.au3>
#include <Array.au3>
#Region ### START Koda GUI section ###
$GUI = GUICreate("FTP tool", 754, 613, 691, 157)
GUICtrlCreateLabel("Host", 16, 16, 26, 17)
GUICtrlCreateLabel("Port", 192, 16, 23, 17)
GUICtrlCreateLabel("Username", 16, 56, 52, 17)
GUICtrlCreateLabel("Password", 16, 88, 50, 17)
GUICtrlCreateLabel("Status : ", 8, 152, 43, 17)
$status = GUICtrlCreateLabel("Not connected", 52, 152, 221, 17)
$host = GUICtrlCreateInput("", 48, 12, 121, 21)
$port = GUICtrlCreateCombo("", 224, 12, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "21|80")
$username = GUICtrlCreateInput("", 79, 52, 121, 21)
$password = GUICtrlCreateInput("", 79, 81, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$connectBtn = GUICtrlCreateButton("CONNECT", 56, 192, 75, 25)
$disconnectBtn = GUICtrlCreateButton("DISCONNECT", 143, 192, 107, 25)
$List = GUICtrlCreateList("", 16, 240, 721, 340, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
If GUICtrlRead($status) = 'Not connected' Then GUICtrlSetState($disconnectBtn, $GUI_DISABLE) ; disable disconnect button if not connected
GUICtrlSetData($port, '21') ; default port
Global $status, $host, $port, $username, $password, $FTPopen, $FTPConnect, $List
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $connectBtn
_connectFTP()
Case $disconnectBtn
_disconnectFTP()
EndSwitch
WEnd
; connection to FTP server
Func _connectFTP()
Local $_host = GUICtrlRead($host) ; host name
Local $_username = GUICtrlRead($username) ; username
Local $_password = GUICtrlRead($password) ; password
Local $_port = GUICtrlRead($port) ; port
Local $FTPopen = _FTP_Open('FTP connection test') ; name of connection
Local $FTPConnect = _FTP_Connect($FTPopen, $_host, $_username, $_password, '', $_port) ; connect
; try to connect to server
If Not @error Then ; if not error
GUICtrlSetData($status, 'Connected') ; set status to connected
GUICtrlSetState($connectBtn, $GUI_DISABLE) ; disable connect button
GUICtrlSetState($disconnectBtn, $GUI_ENABLE) ; enable disconnect button
_listData()
Else
MsgBox(48, 'FTP connection error', "Can't connect to server, error = " & @error) ; if there is connection error
EndIf
EndFunc
; disconnect from FTP server
Func _disconnectFTP()
_FTP_Close($FTPopen)
_FTP_Close($FTPConnect)
GUICtrlSetState($disconnectBtn, $GUI_DISABLE)
GUICtrlSetState($connectBtn, $GUI_ENABLE)
GUICtrlSetData($status, 'Not connected')
_GUICtrlListBox_ResetContent($List)
EndFunc
; list all files on FTP server
Func _listData()
$FTPdirData = _FTP_DirGetCurrent($FTPopen) ; get current dir on server
; Add files in list box
_GUICtrlListBox_BeginUpdate($List)
_GUICtrlListBox_ResetContent($List)
_GUICtrlListBox_Dir($List, "", $FTPdirData, False)
_GUICtrlListBox_EndUpdate($List)
EndFunc