FtpClient.Execute Method (String)

System.Net.FtpClient

Collapse image Expand Image Copy image CopyHover image
Executes a command

Namespace: System.Net.FtpClient
Assembly: System.Net.FtpClient (in System.Net.FtpClient.dll) Version: 1.0.5064.17461

Syntax

C#
public FtpReply Execute(
	string command
)
Visual Basic
Public Function Execute ( 
	command As String
) As FtpReply
Visual C++
public:
virtual FtpReply Execute(
	String^ command
) sealed

Parameters

command
Type: System..::..String
The command to execute

Return Value

Type: FtpReply
The servers reply to the command

Implements

IFtpClient..::..Execute(String)

Examples

C#  Copy imageCopy
using System;
using System.Net;
using System.Net.FtpClient;

namespace Examples {
    static class ExecuteExample {
        public static void Execute() {
            using (FtpClient conn = new FtpClient()) {
                FtpReply reply;

                conn.Host = "localhost";
                conn.Credentials = new NetworkCredential("ftptest", "ftptest");

                if (!(reply = conn.Execute("SITE CHMOD 640 FOO.TXT")).Success) {
                    throw new FtpCommandException(reply);
                }
            }
        }
    }
}

See Also