DEVBUZZ Homepage eVB and FTP using John Clavey's custom SapphireRAS DLL
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | Starting Out

eVB and FTP using John Clavey's custom SapphireRAS DLL
Written by Derek Mitchell  [author's bio]  [read 33871 times]
Edited by Derek

Download the code   Discuss this article   eVB Ver 3.0   

Page 1 

FTP connections within eVB or VB.NET

With the web being an extremely powerful tool in creating truly mobile applications, you can now incorporate the power of the File Transfer Protocol (FTP) right into your eVB or VB.NET applications. Sapphire Solutions Ltd have developed an easy-to-use utility that can connect to a remote FTP server, search for directory listings, upload and download files or directories and create, rename and delete items.

Overview

You can download the demo project of the Sapphire FTP DLL which includes a personal use version of the utility. This utility allows advanced FTP functionality such as:

  • Open and close a FTP session
  • Upload and download files
  • Remote directory navigation
  • Search for files and directories with attributes
  • Remove files and directories
  • Rename files and directories
  • Create directories
  • Upload and download directories (including contents)
  • Check if a remote file exists

Running the Project

After downloading and unzipping the SapphireFTP demo project, you need to add the appropriate version of the SapphireFTP.DLL to the \Windows directory on your Pocket PC. If you are using VB.NET, you will need to include the SapphireFTP.DLL into the application directory of your program instead. You can find the correct DLL in the unzipped project directory under the appropriate sub-directory. Once you have done this you can run the desired project file on the client device.

This demo project is a multi-purpose project that demonstrates the functionality of both the Sapphire FTP and Sapphire RAS utilities. Depending on which DLLs you have installed on your client device, the demo project will allow you to use the associated functionality.

In terms of the FTP functionality, when you enter the FTP explorer you will be able to connect to the remote server (specified under the FTP settings) and perform a variety of functions on both the local device and the remote server.

FTP Settings

The FTP Settings allow you to enter the remote server address, either a domain name or IP address. You can also specify the username and password for the FTP connection. If you require an anonymous connection, use 'Anonymous' as the username and your email address as the password.

The Code

To implement FTP functionality in your own eVB or VB.NET application you only need to create a few simple calls to the DLL.

Example: Linking the DLL using VB.NET

<DllImport("SapphireFTP.dll")> _
Public Function sFTPOpen( _
  ByVal sServer As String, _
  ByVal lPort As Integer, _
  ByVal sUser As String, _
  ByVal sPwd As String, _
  ByVal lPassive As Integer, _
  ByVal lTimeOut As Integer, _
  ByVal lLicence As Integer) As Integer
End Function


<DllImport("SapphireFTP.dll")> _
Public Function sFTPClose( _
  ByVal lLicense As Integer) As Integer
End Function

<DllImport("SapphireFTP.dll")> _
Public Function sFTPPull(_
  ByVal sRemoteFile As String, _
  ByVal sLocalFile As String, _
  ByVal bOverWriteFile As Byte, _
  ByVal lTransferType As Integer, _
  ByVal lLicence As Integer) As Integer
End Function

Example: Linking the DLL using eVB

Declare Function sFTPOpen _
  Lib "SapphireFTP.dll" ( _
  ByVal sServer As String, _
  ByVal lPort As Long, _
  ByVal sUser As String, _
  ByVal sPwd As String, _
  ByVal lPassive As Long, _
  ByVal lTimeOut As Long, _
  ByVal lLicence As Long) As Long

Declare Function
sFTPClose _
  Lib "SapphireFTP.dll" ( _
  ByVal lLicense As Long) As Long

Declare Function sFTPPush _
  Lib "SapphireFTP.dll" ( _
  ByVal sLocalFile As String, _
  ByVal sRemoteFile As String, _
  ByVal lTransferType As Long, _
  ByVal lLicence As Long) As Long

A simple example on how to create an FTP connection is shown below:

lResult = sFTPOpen(sFTPSession, lPort, _
  sFTPUsername,sFTPPassword, lPassive, lTimeOut, _
  SapphireFTPLicence)

  • lResult contains the number of any possible error that may have been encountered.
  • sFTPSession is the name of the remote FTP server.
  • lPort is the port number of the remote FTP server. By default this should be 21.
  • sFTPUsername is the username for the FTP account.
  • sFTPPassword is the password for the FTP account.
  • lPassive is a long specifying whether to use passive mode or not. 1 = Passive, 0 = Non-passive.
  • lTimeOut is the connection timeout in milliseconds.
  • SapphireFTPLicence is the licence number for registered users of the utility. For the demo project, this will be 1234567890.

Below is a simple example on how to download a remote file:

lResult = sFTPPull(sRemoteFile, sLocalFile, _
  FTP_OVERWRITE, FTP_TRANSFER_BINARY, _
  SapphireFTPLicence)

  • lResult contains the number of any possible error that may have been encountered.
  • sRemoteFile is the filename of the remote file.
  • sLocalFile is the name of the file to create when downloading the remote file.
  • FTP_OVERWRITE is a flag to state that the local file will be overwritten if it exists.
  • FTP_TRANSFER_BINARY is a flag to state the remote file is binary opposed to ASCII text.
  • SapphireFTPLicence is the licence number for registered users of the utility. For the demo project, this will be 1234567890.

Please refer to the demo project for a more complete example on how to use the utility including error capturing.

Where to find the demo

The product information page for the latest Sapphire FTP utility allows you to download the personal use version that includes the sample eVB and VB.NET projects with the demo version of the DLL for each target platform. This can be found at www.sapphire-solutions.co.uk/product.asp?product=FTP.

Licence of use

For those that wish to simply experiment with the utility or use it for personal projects, you can use the utility absolutely free of charge.

For those that wish to include the utility into their own commercial applications, they can purchase a royalty-free licence for the utility online at http://www.sapphire-solutions.co.uk. This is a one off payment that allows you to distribute it in any projects created under the registered company. Please refer to the web site for the latest prices.

Other utilities you may find useful

Sapphire Solutions Ltd have a variety of other utilities that you may find useful or vital to your application. Some of these are:

  • Sapphire RAS - Dial up a remote connection and manage phone book.
  • Sapphire GZip - Compress and decompress files into .gz or .zip format.
  • Sapphire Encrypt - Encrypt or decrypt strings or files ensuring its confidentiality.
  • Sapphire IrDA - Use your application to print on an IrDA enabled printer.
  • Sapphire Buttons - Take control of other buttons on your device.

Please check www.sapphire-solutions.co.uk for a full listing of available products.

 

Back to Starting Out | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP