Using Win32 functions in Visual FoxPro Image Gallery
Time
..msdn
CompareFileTime
FileTimeToLocalFileTime
FileTimeToSystemTime
GetFileTime
GetLocalTime
GetSystemTime
GetSystemTimeAdjustment
GetSystemTimeAsFileTime
GetTickCount
GetTimeZoneInformation
LocalFileTimeToFileTime
QueryPerformanceCounter
QueryPerformanceFrequency
SetFileTime
SetTimeZoneInformation
SystemTimeToFileTime
Code examples:
A procedure for setting file times
Building a tree of subdirectories for a given path using FindFile functions
Custom FTP Class for Visual FoxPro application
Downloading files from the FTP server using InternetReadFile
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
How to find when the application started
How to retrieve information about a cache entry (Internet Explorer)
HOWTO: Use the Win32 API to Access File Dates and Times
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: 229  
    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 (50.19.155.235)
    6.28 hrs.Function: 'CreateHardLink'
    Function group: 'File Management'
     Function: 'LookupAccountName'
    Function group: 'Security'
    9.08 hrs.Example: 'Displaying all TCP connections for the local system'
     Example: 'Retrieving geometrical parameters of the system desktop window'
    22.03 hrs.Example: 'Displaying bitmap using the AlphaBlend function'
     Example: 'Creating a directory on the FTP'
    Language: 'C#'
    1 day(s)Function: 'GetProductInfo'
     Example: 'How to play a waveform sound (a WAV file in particular)'
     Example: 'Placing an arbitrary rectangular area of main VFP window on the Clipboard'
     Function: 'NetShareDel'
    Function group: 'Network Management'
    Google
    Advertise here!