Jump to content

Recommended Posts

Posted (edited)

The following function successfully connects to and uploads a local text file named user.dat

I have checked the data being written to the text file when it is created locally using a MsgBox and it appears exactly how it should be written to the file. If I comment out the FileDelete and go and open the file locally it is as expected.

However when I download the file from the FTP server and open it up the text that should be at the end of the file is missing. With each subsequent run more characters are missing.

I added the Sleep(5000) in case the function was closing the FTP connection too quickly before the file could be fully written but it makes no difference. The user.dat file is (should be) approximately 100 bytes so it is tiny.

Any idea why this is happening?

Func UpdateUserData() ; Upload the modified user.dat file
    Local $hOpen = _FTP_Open("myftp")
    Local $hConn = _FTP_Connect($hOpen, "my.ftp.server", "user", "pass", 1, 0, 1, 2)
    If @error Then
        MsgBox(16, "Error", "Connection failed" & @CRLF & @CRLF & "Please contact support")
        _FTP_Close($hConn)
        _FTP_Close($hOpen)
        Exit
    EndIf
    _FTP_FilePut($hConn, @TempDir & "\user.dat", "user.dat") ; Upload the new user.dat file
    Sleep(5000)
    If @error <> 0 Then
        MsgBox(16, "Error", "Couldn't transmit data" & @CRLF & @CRLF & "Please contact support")
        _FTP_Close($hConn)
        _FTP_Close($hOpen)
        Exit
    EndIf
    _FTP_Close($hConn)
    _FTP_Close($hOpen)
    FileDelete(@TempDir & "\user.dat")
EndFunc

 

Edited by Dent
solved
Posted

Solved. Thanks to Dent for working on this so diligently. Turns out if I _FTP_FileDelete the file first then the newly uploaded one is fine. I may well have discovered an FTPEx.au3 

  • Jos locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...