Using Win32 functions in Visual FoxPro Image Gallery
Internet Functions (WinInet)
..msdn
CreateMD5SSOHash
DeleteUrlCacheEntry
DetectAutoProxyUrl
FindCloseUrlCache
FindFirstUrlCacheEntry
FindFirstUrlCacheGroup
FindNextUrlCacheEntry
FindNextUrlCacheGroup
FtpCommand
FtpCreateDirectory
FtpDeleteFile
FtpFindFirstFile
FtpGetCurrentDirectory
FtpGetFile
FtpGetFileSize
FtpOpenFile
FtpPutFile
FtpRemoveDirectory
FtpRenameFile
FtpSetCurrentDirectory
GetUrlCacheEntryInfo
HttpOpenRequest
HttpQueryInfo
HttpSendRequest
InternetAttemptConnect
InternetAutodial
InternetAutodialHangup
InternetCanonicalizeUrl
InternetCheckConnection
InternetCloseHandle
InternetConnect
InternetCrackUrl
InternetDial
InternetFindNextFile
InternetGetConnectedState
InternetGetConnectedStateEx
InternetGetCookie
InternetGetLastResponseInfo
InternetGoOnline
InternetOpen
InternetOpenUrl
InternetQueryDataAvailable
InternetQueryOption
InternetReadFile
InternetSetCookie
InternetSetFilePointer
InternetTimeFromSystemTime
InternetTimeToSystemTime
InternetWriteFile
Code examples:
Custom FTP Class for Visual FoxPro application
Downloading files from the FTP server using InternetReadFile
Reading list of folders and files on FTP server
Retrieving list of files on the FTP directory
Custom FTP Class for Visual FoxPro application

User rating: 10/10 (2 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Programming File Transfer Protocol in Visual FoxPro

The class implements basic FTP operations: connection, directories, downloading and uploading files. All functionality comes from the Microsoft Wininet API library.

Simple FTP manager form built on this class:



Here is a sample code that uses this class.

The interface:
FUNCTION FtpConnect(lcHost, lcUsr, lcPswd)
PROCEDURE FtpDisconnect
PROPERTY IsConnected

FUNCTION GetCurrentDir
FUNCTION SetCurrentDir(lcDir)

FUNCTION RemoveDir(lcDir)
FUNCTION CreateDir(lcDir)
FUNCTION DirExists(lcDir)

FUNCTION Dir2Cursor(lcCursor)

FUNCTION PutToFtp(lcLocalFile, lcRemoteFile, lnChunkSize)
FUNCTION GetFromFtp(lcRemoteFile, lcLocalFile, lnChunkSize)

FUNCTION BeforePutFile(lcLocalFile, lcRemoteFile)
PROCEDURE AfterPutFile(lcLocalFile, lcRemoteFile, lResult)
PROCEDURE OnPutChunk(lcLocalFile, lcRemoteFile, lnBytesWritten)

FUNCTION BeforeGetFile(lcRemoteFile, lcLocalFile)
PROCEDURE AfterGetFile(lcRemoteFile, lcLocalFile, lResult)
PROCEDURE OnGetChunk(lcRemoteFile, lcLocalFile, lnBytesWritten)

See also:
  • Winsock: accessing FTP
  • Using FTPCommand

    More advanced VFP-based FTP solution:
    Download FTP Class Library
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 10/10 (2 votes)
    Rate this code sample:
    • ~
    14272 bytes  
    Created: 2002-11-22 12:28:17  
    Modified: 2010-01-02 14:42:15  
    Visits in 7 days: 277  
    Listed functions:
    CopyMemory
    FileTimeToSystemTime
    FormatMessage
    FtpCreateDirectory
    FtpFindFirstFile
    FtpGetCurrentDirectory
    FtpGetFile
    FtpOpenFile
    FtpPutFile
    FtpRemoveDirectory
    FtpSetCurrentDirectory
    GetLastError
    InternetCloseHandle
    InternetConnect
    InternetFindNextFile
    InternetOpen
    InternetReadFile
    InternetWriteFile
    Printer friendly API declarations
    My comment:
    Because of the VFP one-process and one-thread nature such FTP class -- under some circumstances -- is able to freeze the whole VFP application. With less reliable FTP connections I would choose an external library allowing to drop a frozen FTP connection.

    * * *
    To create a passive data connection to an FTP server, use INTERNET_FLAG_PASSIVE for dwFlags parameter in the InternetConnect call:

    #DEFINE INTERNET_INVALID_PORT_NUMBER 0
    #DEFINE INTERNET_SERVICE_FTP 1
    #DEFINE INTERNET_FLAG_PASSIVE 0x08000000

    nFlags = INTERNET_FLAG_PASSIVE && use 0 for the active mode

    hConnection = InternetConnect(m.hInternet, m.host,;
            INTERNET_INVALID_PORT_NUMBER,;
            m.usr, m.cPsw, INTERNET_SERVICE_FTP, m.nFlags, 0)

    #kwd: sln_ftp.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (23.22.240.119)
    7 sec.
    Function group: 'Remote Application Programming (RAPI)'
    13 sec.Function: 'GetPhysicalMonitorsFromHMONITOR'
    Function group: 'Monitor Configuration (Vista)'
    19 sec.
    Function group: 'COM'
    25 sec.Links
    33 sec.Function: 'FtpSetCurrentDirectory'
    Function group: 'Internet Functions (WinInet)'
    39 sec.Function: 'NetShareAdd'
    Function group: 'Network Management'
    44 sec.
    52 sec.All Functions
    58 sec.Function: 'CeCreateProcess'
    Function group: 'Remote Application Programming (RAPI)'
    1.2 min.Example: 'Using Month Calendar Control (VFP9, Comctl32.dll)'
    Google
    Advertise here!