Sign in to follow this  
Followers 0
Delta01

_FTPGetFile()

7 posts in this topic

#1 ·  Posted (edited)

Well, I'm trying to download a file from my FTP server. I get the file downloaded, but then the script says "AutoIt has stopped responding"

How can I fix this, my code is below...

#Include <_FTP.au3>

$server = 'server.host.com'
$username = 'username'
$pass = 'password'
$dllhandle = DllOpen('wininet.dll')
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
_FTPGetFile($Conn,"/hello.txt", @ScriptDir & "/hello.txt", 0, 0)
$Ftpc = _FTPClose($Open)
DllClose($dllhandle)



;===============================================================================
;
; Function Name:    _FTPGetFile()
; Description:      Get file from a FTP server.
; Parameter(s):     $l_FTPSession    - The Long from _FTPConnect()
;                   $s_LocalFile     - The local file.
;                   $s_RemoteFile      - The remote Location for the file.
;                   $l_Flags        - Special flags.
;                   $l_Context      - I dont got a clue what this does.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                   On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPGetFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)

    Local $ai_FTPGetFile = DllCall('wininet.dll', 'int', 'FtpGetFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_FTPGetFile[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_FTPGetFile[0]
    
EndFunc

What am I doing wrong?

Edited by Delta01

Share this post


Link to post
Share on other sites



#Include <_FTP.au3>

$server = 'server.host.com'
$username = 'username'
$pass = 'password'
$dllhandle = DllOpen('wininet.dll')
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
_FTPGetFile($Conn,"/hello.txt", @ScriptDir & "/hello.txt", 0, 0)
$Ftpc = _FTPClose($Open)
DllClose($dllhandle)


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

Huh? Did you change anything?

Share this post


Link to post
Share on other sites

yes, i removed this part , which is declare in the <FTP.au3>, why do you try to put it in your code ?

;===============================================================================
;
; Function Name:    _FTPGetFile()
; Description:    Get file from a FTP server.
; Parameter(s):  $l_FTPSession  - The Long from _FTPConnect()
;                  $s_LocalFile  - The local file.
;                  $s_RemoteFile      - The remote Location for the file.
;                  $l_Flags     - Special flags.
;                  $l_Context     - I dont got a clue what this does.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPGetFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)

    Local $ai_FTPGetFile = DllCall('wininet.dll', 'int', 'FtpGetFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_FTPGetFile[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_FTPGetFile[0]
    
EndFunc

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

Because it has the other code I need like, FTPOPen()

Share this post


Link to post
Share on other sites

Bump

Share this post


Link to post
Share on other sites

Bump.......

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0