Jump: Search:

Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access 2007/2010 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2010 (32 bit), 2007, 2003, 2002, 2000, and
Visual Basic 6.0!

Also available for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

 

 
Royalty free source code library modules for Microsoft Access, VB6, VBA, OfficeRoyalty free source code library modules for Microsoft Access, VB6, VBA, OfficeVBA and VB6 Source Code Library Download the free trial version of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA
Category: Internet/Web : HTTP/FTP
Description: Code to work with Internet protocols such as HTTP and FTP (File Transfer Protocol), and working with the Internet Transfer control

Class: CInternetFTP

Working with the FTP standard to get to data, connections and sessions on a remote FTP site

You can use the functionality in this class to connect to an FTP server, get file directories and information, create directories, and send and receive files. This class works directly through the WININET.DLL library, so it requires no additional OCX or control files. This means you can distribute simple FTP functionality with your application with little overhead.

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CInternetFTP class
ConnectionHandle Property Get the handle to the Internet connection. After establishing a session to WININET.DLL with the OpenSession() method, you connect to an FTP server with the Connect() method. Once this call has been made, and returned successfully, this property is the connection handle value returned to the class by the WININET.DLL resource.
FTPCurDir Property Gets the current directory as set on the FTP server. This property is read-only. To change the directory on the FTP server, use the RemoteChDir method.
FTPDirAttrNumber Property Get the file attributes of the specified item in the current directory. This property represents a collection of the attributes of the items in the current directory on the FTP server. Use this property to return the attributes of the file or directory at the specified position in the collection. The value of this property is a long integer defined by the dwFileAttributes parameter of the Windows API WIN32_FIND_DATA type. Possible values are defined by the class constants that start with "FILE_ATTRIBUTE".
FTPDirAttrString Property Gets the file attributes of the specified item in the current directory as a readable string. This property represents a collection of the attributes of the items in the current directory on the FTP server as a readable string. Use this property to return the attributes of the file or directory at the specified position in the collection. To get the readable form of the long integer attributes, this property calls the class GetEnglishAttributes() private method for translation.
FTPDirCount Property Gets the count of entries in the current directory. Use this property to determine how many entries there are in the current FTP server directory, and consequently, the class directory collection. For example, you can use this property as a loop boundary when displaying all the items in the current directory: For intCounter = 1 To MyFTP.FTPDirCount Debug.Print MyFTP.FTPDirEntry(intCounter) Next intCounter This value is one-based, meaning that the first item in the directory collection is item 1.
FTPDirEntry Property Gets the name of the specified file or sub-directory in the current directory. This property represents a collection of the names of the items in the current directory on the FTP server. Use this property to return the name of the file or directory at the specified position in the collection.
FTPDirSize Property Gets the file size of the specified item in the current directory. This property represents a collection of the sizes of the items in the current directory on the FTP server. Use this property to return the size of the file at the specified position in the collection. This class defines directory entries as having a size of 0 bytes.
LastDLLError Property Gets the last error raised by a call to a DLL function. This class saves the VB Err.LastDLLError value after every call to the WININET.DLL resource. This means that error information can be retrieved by using this property without having to directly access the VB Err object.
Password Property Gets the current login password Many FTP servers support anonymous logins. This means that you can log into the server as a guest without having a pre-defined account or password. If you are accessing an FTP server that requires an existing user account and password, set this property to your password before calling the Connect() method. If you do not specify a value for this property, a blank password is used, allowing access to anonymous FTP servers.
ProxyString Property Gets the current proxy server. If you attempt to connect to an FTP site through a proxy server, set this property before calling the OpenSession() method. Set this property to the name of the proxy server (or servers) to use. If you do not specify a value for this property, the OpenSession() method opens the Internet session without any proxy server information. The Win32 Internet functions only recognize CERN type proxies (HTTP only) and the TIS FTP gateway (FTP only). The Win32 Internet functions also support SOCKS proxies. FTP and Gopher requests can be made through a CERN type proxy either by changing them to an HTTP request or by using the WININET.DLL InternetOpenUrl() function.
Server Property Set the name of the FTP server to connect to. Before performing FTP operations, you must specify the URL of the FTP site you want to connect to. Set this property to a valid FTP URL, such as ftp.microsoft.com before calling Connect() method.
SessionActive Property Returns whether there is an active session open to an FTP site. This value is True if the OpenSession() method has been called successfully. You can check this property to ensure a session is active before performing subsequent FTP operations.
SessionHandle Property Gets the handle to the Internet session. Before performing any FTP operations, you most establish a session to the WININET.DLL resource. Call the OpenSession() method to do this. Once this call has been made, and returned successfully, this property is the handle value returned to the class by the WININET.DLL resource.
TransferType Property Gets the current TransferType setting. This property tells the class whether to do ASCII or Binary transfers for subsequent calls to the GetFile() and PutFile() methods. Set this value according to the EnumFTPTransferType enumerated type.
username Property Set the user name
Class_Initialize Initialize Set initial values to defaults which may be overridden with property settings
ClearCollections Private Clears the directory collections
ClearDLLError Private Clears the class's last DLL error
CloseSession Method Closes the current handles to the Internet. Call this method when you are finished using the FTP class.
Connect Method Establishes a connection to the named FTP server. The class Server property must be set to a valid FTP server URL address before calling this method.
CreateDirectory Method Creates the specified directory on the current FTP site. You must have sufficient permissions on the FTP server to create a directory. Most anonymous FTP connections do not allow the creation or deletion of directories. Check the class LastDLLError property for information on failure results of this method.
Disconnect Method Disconnects the link to the server. Call this method to disconnect from an FTP server that was connected by the Connect() method. If there is no active server connection, this method fails silently.
FTPEnumerateDir Private Fills the class collections with the contents of the current directory.
GetDLLError Private Set the class Last DLL error properties
GetEnglishAttributes Private Returns a human readable version of an FTP directory entry
GetFile Method Retreives the specified file from the remote server. If the local file exists, it is overwritten. In order to retrieve a file, your FTP login account must have read permission on the file.
GetNameFromFTPPath Private Returns the name part of a fully qualified FTP file name. This function differs from other path parsing function in Total VB SourceBook in that it uses the forward slash (/) character for path delimiting. This is because FTP sites work with the UNIX standard for paths.
GetPathFromFTPPath Private Returns the path part of a fully qualified FTP file name.
OpenSession Method Opens a session to the Interenet resource. Before accessing Internet functionality through the WININET.DLL resource, you must open a session to it. Do this by calling the OpenSession() method. This method establishes a session to the DLL and obtains a handle to be used for subsequent operations.
PutFile Method Uploads the named local file to the remote server. You must have the appropriate permissions on the FTP server for the directory you are trying to write to.
RemoteChDir Method Changes the directory on the remote server. A successful call to this method causes the class directory collections to be refreshed.
TrimNulls Private Returns the passed string terminated at the first null

Overview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright © FMS, Inc., Vienna, Virginia
Celebrating our 26th Year of Software Excellence