|
You last visited: Today at 06:14
Advertisement
List files from FTP in listbox
Discussion on List files from FTP in listbox within the AutoIt forum part of the Coders Den category.
07/26/2015, 10:42
|
#1
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
List files from FTP in listbox
Hi, i have problem with listing data in GUI listbox, when i connect to server i get 0 files
$FTPopen is ftp session
Code:
; 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
|
|
|
07/26/2015, 13:01
|
#2
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Are you sure that you're using the connect handle instead of the session handle?
$FTPopen not come from _FTP_Open but from _FTP_Connect
|
|
|
07/26/2015, 17:41
|
#3
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
Yes im sure look at whole script
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
|
|
|
07/26/2015, 19:18
|
#4
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
First of all don't declare local variables if you're using them global (especially not in functions!!!).
Also I was right, you're using $FTPopen (from _FTP_Open) while _FTP_DirGetCurrent requires the _FTP_Connect handle whoch is $FTPconnect.
You don't believe me? Check the documentation:
Quote:
$hFTPSession - as returned by _FTP_Connect().
|
|
|
|
07/26/2015, 19:42
|
#5
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
Quote:
Originally Posted by alpines
First of all don't declare local variables if you're using them global (especially not in functions!!!).
Also I was right, you're using $FTPopen (from _FTP_Open) while _FTP_DirGetCurrent requires the _FTP_Connect handle whoch is $FTPconnect.
You don't believe me? Check the documentation:
|
Ok i added msgbox to see error and i removed Local from $FTPopen and $FTPConnect and i get this in msgbox "0, @error = -1, @extended = 12018"
Code:
; get current dir on server
$FTPdirData = _FTP_DirGetCurrent($FTPopen)
MsgBox(0, "", $FTPdirData & ', @error = ' & @error & ' , @extended = ' & @extended)
By the way if i use script like this i get all files from server
Code:
#RequireAdmin
#include <Array.au3>
#include <FTPEx.au3>
#include <MsgBoxConstants.au3>
Local $sServer = '*******'
Local $sUsername = '*******'
Local $sPass = '*********'
Local $hOpen = _FTP_Open('MyFTP Control', 0)
If Not @error Then
; passive allows most protected FTPs to answer
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
If Not @error Then
Local $aFile = _FTP_ListToArrayEx($hConn, 0)
If Not @error Then
_ArrayDisplay($aFile)
Else
MsgBox($MB_SYSTEMMODAL, "Error", '_FTP_ListToArrayEx($Conn, 0)' & @CRLF & _
'@error = ' & @error & ' @extended = ' & @extended)
EndIf
Local $iFtpc = _FTP_Close($hConn)
Else
MsgBox($MB_SYSTEMMODAL, "Error", '_FTP_Connect($Open, ' & $sServer & ', ' & $sUsername & ', ' & $sPass & ')' & @CRLF & _
'@error = ' & @error & ' @extended = ' & @extended)
EndIf
Local $iFtpo = _FTP_Close($hOpen)
Else
MsgBox($MB_SYSTEMMODAL, "Error", "_FTP_Open('MyFTP Control')" & @CRLF & _
'@error = ' & @error & ' @extended = ' & @extended)
EndIf
look here on image
And when i use it like this i got im msgbox "/, @error = 0, @extended = 0", so where is files ? i got only drives
Code:
; list all files on FTP server
Func _listData()
; get current dir on server
$FTPdirData = _FTP_DirGetCurrent($FTPConnect)
MsgBox(0, "", $FTPdirData & ', @error = ' & @error & ' , @extended = ' & @extended)
; Add files in list box
_GUICtrlListBox_BeginUpdate($List)
_GUICtrlListBox_ResetContent($List)
_GUICtrlListBox_Dir($List, "", $FTPdirData, False)
_GUICtrlListBox_EndUpdate($List)
EndFunc
|
|
|
07/26/2015, 19:47
|
#6
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
You're not even listening. The handle you're passing to _FTP_DirGetCurrent is wrong. Don't use the handle from _FTP_Open, use the handle from _FTP_Connect!
|
|
|
07/26/2015, 20:02
|
#7
|
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
|
I used handle from _FTP_Connect look on my last edit, and now i got drives on my computer
|
|
|
|
Similar Threads
|
[List]251 Files zYan + Description -- ENG/ITA
11/27/2012 - S4 League Hacks, Bots, Cheats & Exploits - 35 Replies
Hello
Note: I've got some things from hypnotize!
Note2:All text can be changed.
Note 3: Some things are only clientside,so don't ask me "why i can't be a gm!!111!"
List will continue soon.
|
1678 files hongkong list
03/20/2012 - Metin2 Private Server - 4 Replies
wie heißt die hongkong list von den 1678 files von daroo?
|
[TuT]Offi Files Honor List
11/14/2010 - Flyff Private Server - 9 Replies
Hallo Elitepvpers :mofo:
Heute möchte ich euch zeigen, wie man die Honor List Bearbeitet!
das ist wenn man z.B 15000 Aibatts killt steht über deinem Namen :
Aibatt Hunter
Wir wollen es so bearbeiten, sodass man nicht 15000 Aibatts killn muss sondern nur 5!
Wir öffnen die honorList.txt(nicht .txt.txt!!!)
|
[RQ] List .lua files
11/05/2010 - S4 League - 2 Replies
hey i was wondering. can anybody list the .lua test files for me?
i want to change the mind shock licence into the claw :)
i cant do Mind Energy since i have did the licence
|
List of .ISO FILES
05/31/2009 - Soldier Front Philippines - 39 Replies
ANNOUNCEMENT: i will just raise the no. of Downloads up to 200,..after that ill ask our MODS to close this tread.
i think that would be enough.
im just thinking the other side of the coin. Lets be fair to other players who doesnt have hack.
hope you tend to Understand Guys.
peaceout - :handsdown:DC914:handsdown:
intended for PSF only
|
All times are GMT +1. The time now is 06:14.
|
|