Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Catalyst Sockettools FTP Control
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00548228
Message ID:
00549251
Views:
16
>I'm currently evaluating Catalyst's SocketTools suite of controls... I'm trying to get a simple list of the files in an FTP Directory (using the FTP control of course)... It connects to the FTP server just fine.. I issue a FILELIST commmand (it sends a list of all the files retrieved to the FileList event).. nothing comes through. Yes, there are files on the FTP site. I loaded the VB demo, and connected to the same server. Works great. As far as I can figure, the EVENTS of the FTP control don't fire at ALL. None of them do. Even the connect and disconnect don't work.
>
>Anyone seen this before? i've seen something similiar with a DynaZip control (where the events just didn't work), but thankfully I didn't need the events... Am I doing something wrong?
>
>TIA!


Sorry, I completely forgot to follow up my original message. Here's some sample code that works for me - it's taken right out of one of my classes so you'll probably have to modify it to make it work. Basically, I've got a class that can connect to a web server, checks for any new downloads in the FTP directory, then downloads them. This particular class ignores subdirectories, but you should be able to parse that out pretty easily (just see the code that I use to ignore them).

HTH
WITH THIS.oFTP
  	     .HostName = THIS.cFTPServer
		 .RemotePort = THIS.cFTPPort
		 .UserName = THIS.cUserName
		 .Password = THIS.cPassword
		
		 THIS.AddTask("Connecting to server via FTP.")
		
		 IF .Connect() = 0
		    * We connected OK
		    THIS.AddTask("Connection successful.")
		    THIS.AddTask("Downloading: " + tcFile)
           
		    lnResult = .GetFile(THIS.cUpdatePath + JUSTFNAME(tcFile), tcLinkFile)
		   
		    IF lnResult <> 0
		       * Error
		       .Disconnect()
		       THIS.AddTask("Error retrieving file.")
		    ELSE
		       * Successful
			   toTransfer.AddFile(ADDBS(THIS.cUpdatePath) + tcFile)
 
 			   IF This.DoesFTPFileExist(JUSTSTEM(tcLinkFile) + ".FPT", This.oFTP)

			      lnResult = .GetFile(THIS.cUpdatePath + JUSTSTEM(tcFile) + ".FPT", JUSTSTEM(tcLinkFile) + ".FPT") 

			      IF lnResult <> 0
			         * Error
			         .Disconnect()
			         THIS.AddTask("Error retrieving FPT file.")
			      ELSE
	   			      .Disconnect()
	   			      llError = .F.
			      ENDIF
			     
			   ELSE
			      .Disconnect()
		          llError = .F.
			  
			   ENDIF
			      			  
		    ENDIF
		 ELSE
		    * Error
		    .Disconnect()
		    THIS.AddTask("An error occurred while attempting to connect to the server.")
		 ENDIF
ENDWITH

--------------
FUNCTION DoesFTPFileExist
LPARAMETERS tcFile, toFTP
LOCAL llExist, ;
      lcFile, ;
      lcFileName      

* Parsing is dependent on FTP server - must be UNIX filenames, not DOS

IF VARTYPE(tcFile) = "C" and VARTYPE(toFTP) = "O"
	lcFile = ""
	
	IF toFTP.OpenDirectory("/") = 0
	   toFTP.ParseList = .F.
	   
	   DO WHILE toFTP.Read(@lcFile, 1000) > 0
	      * Move on to the next one if it's a directory
	      
	      IF LEFT(lcFile, 1) = "d"
	         LOOP
	      ENDIF

	      * Parse out the file name
	      
	      lcFileName = SUBSTR(lcFile, 60, LEN(lcFile) - 61)
	      
	      IF ALLTRIM(UPPER(tcFile)) = ALLTRIM(UPPER(lcFileName))
	         llExist = .T.
	         EXIT
	      ENDIF
	        
	   ENDDO
	   
	   toFTP.CloseDirectory()
	ELSE
	   * Error
	ENDIF
ELSE
	* Bad parameters
ENDIF

RETURN llExist
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform