Java and .NET components, FTP, TELNET, SMTP, POP3, IMAP, HTTP, SSH
Home Search Knowledge Base Support

Support

Click here for access to live sales support.

For technical support please submit a ticket to the Help Desk.

 

Java and .NET Help

iTunes Gift Card Offer

For a limited time get a $50.00 iTunes gift card free with qualifying purchase.

Click for details.


News

JSCAPE Secure FTP Server 7.0 Released
08/20/2010 03:31 AM

JSCAPE launches Employee Giving Program
07/03/2010 08:26 AM

SSH Factory 3.6 Released
07/03/2010 06:22 AM

Secure iNet Factory 8.5 Released
07/03/2010 06:07 AM

Secure FTP Factory 8.5 Released
07/03/2010 06:03 AM

Secure FTP Applet 6.2 Released
06/10/2010 02:23 PM

more...


Tutorials

Enabling Phone Authentication
04/08/2009 11:24 AM

Detecting and Handling Brute Force Password Attacks
01/29/2009 09:44 AM

Creating a Domain
12/15/2008 11:33 AM

Public key authentication with SFTP
10/02/2008 07:59 AM

Formatting MimeMessages using .NET
09/14/2008 04:31 PM

Communicating with an IMAP4 server in .NET
09/14/2008 03:54 PM

more...


Articles

Open up corporate data to your partners
08/03/2010 10:01 PM

Access vital corporate documents on the go
07/01/2010 02:15 PM

SFTP and Encryption
05/17/2010 09:52 PM

Streamlining web uploads with ZIP archives
12/14/2009 10:11 AM

Using regular expressions in complex trigger conditions
09/08/2009 07:42 AM

Using custom forms to automate business processes
07/03/2009 08:51 AM

more...


Feedback

Request a feature or component

Request a Java or .NET component


 

Changing Remote File Permissions - Part 1

By: Rick Stevens
March 2nd 2005

Audience: Novice

Often times it is necessary to change permissions on one or more remote files. Secure FTP Factory for .NET easily allows you to issue commands directly to the FTP server.

Most FTP servers are configured to support additional commands, such as the SITE command. By using the Secure FTP Factory for .NET IssueCommand() method, you can send commands directly to your FTP server.

This series of articles will provide you with everything you need to:

  • Issue the chmod command for a set of image (.jpg) files, and
  • Add a UI element to the example interface to modify remote file permissions.

Note

Some windows servers may translate the chmod command into a valid windows permissions command.


In this, part one of Changing Remote File Permissions, you'll learn how to use the IssueCommand() method to modify the permissions on a set of remote image files on a UNIX server. Take the case where more than one person (with unique privileges) is uploading images for your company web site and you want to modify the permissions.

You should have the appropriate login credentials for your FTP server in order to execute the chmod command.

You can download a free evaluation version of Secure FTP Factory for .NET. You can also download all the code you'll need for this article -- it will make things easier as we progress through the steps.

Setup

We'll begin by creating a new C# console application called FtpExample. In it we'll need to add the Jscape.Ftp.dll reference and include the following using statements. See the Secure FTP Factory for .NET User Guide for more information about adding a reference to your project.

using System;
using System.Collections;
using System.IO;
using System.Text;
using Jscape.Ftp;

Next, we'll create the basic structure for our console project.

using System;
using System.Collections;
using System.IO;
using System.Text;
using Jscape.Ftp;
namespace FtpExample { public class FtpExample { public FtpExample() { } [STAThread] static void Main() { } } }

Secure FTP Factory for .NET exposes many properties and methods that allow you to connect to an FTP server, trap various events, retrieve information from, and send commands to the server. Now that we have the basic structure in place, we can begin adding our code to accomplish these tasks.

Instantiating the Ftp class

The code necessary to create and ftp instance is straight-forward. The Ftp constructor provides many overloads to accommodate different needs. You can review the API documentation for more information. For us, we'll pass the hostname, username, and password as parameters to the constructor. You will need to pass in the appropriate parameters for your server.

using System;
using System.Collections;
using System.IO;
using System.Text;
using Jscape.Ftp;

namespace FtpExample {

   public class FtpExample {

      public FtpExample() {
Ftp myFtp = new Ftp("hostname","username","password"); // turn on debug mode myFtp.Debug = true;
} [STAThread] static void Main() { } } }

Subscribing to and Trapping events

For this article, we only need to verify the connection to the server. The Jscape.Ftp component makes this easy by providing OnConnect and OnDisconnect delegates to which we can subscribe. You can find a listing of all delegates in the API reference.

using System;
using System.Collections;
using System.IO;
using System.Text;
using Jscape.Ftp;

namespace FtpExample {

   public class FtpExample {

      public FtpExample() {
         Ftp myFtp = new Ftp("hostname","username","password");
         // turn on debug mode
         myFtp.Debug = true;
myFtp.FtpConnectedEvent += new FtpConnectEventHandler(OnConnected); myFtp.FtpDisconnectedEvent += new FtpConnectEventHandler(OnDisconnected);
} [STAThread] static void Main() { } } }

Now, we simply add the event handlers to our project to inform us of the current connection state.

using System;
using System.Collections;
using System.IO;
using System.Text;
using Jscape.Ftp;

namespace FtpExample {
   public class FtpExample {

      public FtpExample() {
         Ftp myFtp = new Ftp("hostname","username","password");
         // turn on debug mode
         myFtp.Debug = true;

         myFtp.FtpConnectedEvent += new FtpConnectEventHandler(OnConnected);
         myFtp.FtpDisconnectedEvent += new FtpConnectEventHandler(OnDisconnected);
      }

      [STAThread]
      static void Main() {
      }

private void OnConnected(object sender, FtpConnectEventArgs e) { Console.WriteLine("Connected to " + e.HostName + "\r\n"); } private void OnDisconnected(object sender, FtpConnectEventArgs e) { Console.WriteLine("Disconnected."); }
} }

We now have our completed structure and are ready to begin some real work.

Page 1  Page 2