Sign in to follow this  
Followers 0
Speedy13

_FTP_FindFileFirst Help Please

7 posts in this topic

I'm trying to use function _FTP_FindFileFirst, but I'm not having any luck. I'm using the example code from the AutoIt Help. I've searched the forums with no success on finding an answer. I keep getting "$Filename = . attribute = 16 -> Error code: 0" for my results

#include <FTPEx.au3>

Local $server = 'ftp.*****.com'
Local $username = '*****@*****.com'
Local $pass = '*****'

Local $Open = _FTP_Open('MyFTP Control')
Local $Conn = _FTP_Connect($Open, $server, $username, $pass)

Local $h_Handle
Local $aFile = _FTP_FindFileFirst($Conn, "/", $h_Handle)
ConsoleWrite('$Filename = ' & $aFile[10] & ' attribute = ' & $aFile[1] & ' -> Error code: ' & @error & @CRLF)

Local $FindClose = _FTP_FindFileClose($h_Handle)

Local $Ftpc = _FTP_Close($Open)

If anyone could help me, I'd really appreciate it.

Thanks

Share this post


Link to post
Share on other sites



Speedy13,

Are you able to access the files using Filezilla (freeware remote file manager)?

Verify the directory that the files are in with Filezilla.

Also, verify that you're OPEN was successfull with something like this

Local $Conn = _FTP_Connect($Open, $server, $username, $pass)
 If $conn = 0 Then
  msgbox( $mb_ok,' FTP Connect Error - Error code = ' & @error,  _WinAPI_GetLastErrorMessage() )
  exit
 endif

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

kylomas,

Thank you for your reply. I am currently using Filezilla as my FTP.

Also, I can create a _FTP_ListToArray just fine. For some strange reason I can't get _FTP_FindFileFirst to work for me. I trying to find a file in the root directory of the ftp.

I believe the second parameter ($s_RemotePath) is what is giving me a hard time. I even tried looking in a directory with no success.

Here are some of the parameters I've tried:

Local $aFile = _FTP_FindFileFirst($Conn, "", $h_Handle)

Local $aFile = _FTP_FindFileFirst($Conn, "/", $h_Handle)

Local $aFile = _FTP_FindFileFirst($Conn, "/Test/", $h_Handle)

Speedy13

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Speedy13,

I agree, it seems to be something with the remote directory parm but I don't see what. This is part of a routine that I use to display remote files

Local $hfl
 Local $a_files  = _FTP_findfilefirst($conn,"/www/klms/",$hfl)
 If @error = -1 Then
  GUICtrlSetData($lbl020,$file_count & ' files available for download...')
  Return
 endif
 GUICtrlSetData($edt010,$a_files[10] & @crlf, 1)
 $file_count += 1

kylomas

edit: what does _arraydisplay($afile) show?

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

kylomas,

I ran _arraydisplay($afile) and it did opened "Array: ListView Display" window with my files.

I guess I'm out of luck with _FTP_FindFileFirst function.

Speedy13

Share this post


Link to post
Share on other sites

kylomas,

Thank you for your help. I figured out the problem. I have to do _FTP_FindFileFirst and then _FTP_FindFileNext twice before I get to my first file. Below is what I'm dealing with

1) .

2) ..

3) File #1

4) File #2

5) File #3

etc..

Is there anyway for _FTP_FindFileFirst not to come back with . and ..? If not, then that is ok. I can work with this now.

Speedy13

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Speedy,

Is there anyway for _FTP_FindFileFirst not to come back with . and ..? If not, then that is ok. I can work with this now.

These almost look like dir navigation pointers.

Thank you for your help. I figured out the problem. I have to do _FTP_FindFileFirst and then _FTP_FindFileNext

I should have posted my entire file routine, you would have seen this immediately.

Good Luck,

kylomas

edit: additional info

at my host the array returned by filefindfirst looks like this

[0]|11
[1]|128
[2]|0
[3]|0
[4]|0
[5]|0
[6]|1373158400
[7]|30278350
[8]|0
[9]|20765
[10]|klog.MAIN010-ADMIN010-20130204-123106.txt
[11]|

My files are not in the root directory, however.

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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