FTP .NET Component
The FTP .NET component found in Secure FTP Factory for .NET provides an easy to use API for the transfer
of files to / from an FTP server using FTP (File Transfer Protocol).
 
Features
- Secure FTP support - Includes support for both implicit and expicit SSL transfers.
- Transfer mode support - Includes both ASCII and Binary modes
for transferring text or binary data.
- Firewall support - Easily connect to FTP servers from behind
a firewall.
- Automatic transfer mode detection - Sets transfer mode automatically
based on file extension.
- Multiple file transfer - Transfer one or more files matching
a regular expression e.g. *.txt
- Directory transfer - Transfer entire directories recursively,
automatically recreating directory structure on receiving side.
- Progress monitor - Built in event listeners to track the progress
of file transfers including bytes transferred, total time and
total bytes transferred.
- Timeout support - Generates an exception when connection to
FTP server cannot be established or data cannot be read from FTP
server within defined timeout.
- File transfer interruption - Ability to interrupt file transfers
at any time.
- Message logging - Ability to stream messages exchanged between
FTP client and server to a file.
- Memory based uploads - Ability to upload a file that exists
in memory to FTP server.
- Memory based downloads - Ability to download file from FTP server
and store in memory.
- Remote filesize and date - Easily query a remote file on FTP
server for it's size and last modification timestamp.
- Command execution - Send arbitrary commands to FTP server.
- Append support - Upload files to FTP server appending data sent
to the end of of a file.
- Resume support - Resume interrupted file transfers.
- and more!!
Code Example
The following C# example demonstrates how to connect to an FTP server
and perform a directory listing using the FTP .NET component.
/*
* FtpExample.cs
*
* Copyright (c) 1999-2005 JSCAPE, LLC
* 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
* All rights reserved.
*
* This software is the confidential and proprietary information of
* JScape ("Confidential Information"). You shall not disclose such
* Confidential Information and shall use it only in accordance with
* the terms of the license agreement you entered into with JSCAPE.
*/
using System;
using System.IO;
using System.Text;
using System.Threading;
using Jscape.Ftp;
namespace FtpExample {
public class FtpExample {
public Ftp myFtp = null;
public FtpExample(string hostname, string username, string password) {
myFtp = new Ftp(hostname,username,password);
myFtp.FtpConnectedEvent += new FtpConnectEventHandler(OnConnected);
myFtp.FtpDisconnectedEvent += new FtpConnectEventHandler(OnDisconnected);
myFtp.Connect();
Console.WriteLine( myFtp.GetDirListingAsString("*.*") );
myFtp.Disconnect();
}
[STAThread]
static void Main(string[] args) {
string hostname,username,password;
Console.WriteLine("Enter FTP server host name or IP");
hostname = Console.ReadLine();
Console.WriteLine("Enter User name");
hostname = Console.ReadLine();
Console.WriteLine("Enter Password");
hostname = Console.ReadLine();
FtpExample ftpExample = new FtpExample(hostname,username,password);
}
private void OnConnected(object sender, FtpConnectEventArgs e) {
Console.WriteLine("Connected to " + e.HostName);
}
private void OnDisconnected(object sender, FtpConnectEventArgs e) {
Console.WriteLine("Disconnected " + e.HostName);
}
}
}
 
|
|