Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to print a bitmap file
How to display Windows On-Screen Keyboard
Winsock: sending email messages (SMTP, port 25)
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
System Image List Viewer
Printing Image File, programmatically set print page orientation to landscape
Creating the Save dialog box to specify the drive, directory, and name of a file to save
How to convert a bitmap file to monochrome format (1 bpp)
Using EnumPrinters function to enumerate locally installed printers
Custom HttpRequest class (WinHTTP)
Mapping and disconnecting network drives
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
How to download a file from the FTP server using FtpGetFile
The window and its ancestors
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Drawing Windows predefined bitmaps using the LoadBitmap functions
Custom FTP Class for Visual FoxPro application
Displaying the associated icons and descriptions for files and folders
How to activate Windows Calculator
Displaying icons in the system tray (VFP9)
Sending email messages with Simple MAPI
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: 181  
    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 (184.73.7.143)
    5 sec.Example: 'Subclassing CommandButton control to create BackColor property'
    8 sec.Example: 'Enumerating printer drivers installed'
    1.94 hrs.Example: 'How to empty the Recycle Bin'
    2.38 hrs.Example: 'Enumerating Processes -- Win9*'
    2.39 hrs.Function: 'NetUserChangePassword'
    Google
    Advertise here!