Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Enumerating data formats currently available on the clipboard
Winsock: sending email messages (SMTP, port 25)
Detecting changes in connections to removable drives (VFP9)
Custom FTP Class for Visual FoxPro application
Splash Screen for the VFP application
How to download a file from the FTP server using FtpGetFile
How to activate Windows Calculator
Mapping and disconnecting network drives
Custom HttpRequest class (WinHTTP)
How to convert a bitmap file to monochrome format (1 bpp)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Establishing connection using the SQLDriverConnect
Using Font and Text functions
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Displaying bitmap using the AlphaBlend function
Using WM_COPYDATA for interprocess communication (VFP9)
Extensible Storage Engine class library
How to play AVI file on the _screen
Custom HttpRequest class (WinINet)
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: 230  
    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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.224.75.101)
    4 sec.Example: 'Using mailslots to send messages on the network'
    55.53 min.Function: 'FindWindowEx'
    55.58 min.Function: 'DllGetVersion'
    Function group: 'Shell Functions'
    1.65 hrs.Function: 'LockWindowUpdate'
    Function group: 'Painting and Drawing'
     Function: 'GdipTranslateWorldTransform'
    Function group: 'GDI+ Graphics'
    8.54 hrs.Example: 'Reading and setting the priority class values for the current process and thread'
    12.33 hrs.Example: 'Retrieving the name of the default printer for the current user on the local computer (Win NT/XP)'
    20.65 hrs.Example: 'Using FrameRgn for displaying system colors'
    1 day(s)Function: 'GetUserName'
     Example: 'Enumerating Processes -- Win9*'
    Google
    Advertise here!