다음을 통해 공유


FTP Client Technology Sample

This sample shows how to use methods of the FtpWebRequest and FtpWebResponse classes to upload and download files to and from an FTP server.

For information about using the samples, see the following topics:

To build the sample using the Command Prompt

  1. Open the Command Prompt window and navigate to the CS subdirectory under the FTPSample directory. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.

  2. Type msbuild FTPSample.sln at the command line.

To build the sample using Visual Studio

  1. Open Windows Explorer and navigate to the CS subdirectory under the FTPSample directory.

  2. Double-click the icon for FTPSample.sln to open the file in Visual Studio.

  3. In the Build menu, select Build Solution.

The application is built in the default \bin or \bin\Debug directory.

To run the sample

  1. Navigate to the directory that contains the new executable file, using the Command Prompt window.

  2. Type FTPSample.exe /? at the command line to get help on using this sample.

    Type FTPSample.exe <FTP download URL> at the command line to download a file from an FTP server. For example, FtpSample ftp://myserver/download.txt.

    Type FTPSample.exe <local file> <FTP upload URL> at the command line to upload a file to an FTP server. For example, FtpSample upload.txt ftp://myserver/upload.txt.

    Type FTPSample.exe /list <FTP list URL> at the command line to list the files on an FTP server.

    NoteNote

    The sample builds a console application. You must launch it using the Command Prompt window to see its output.

Remarks

The sample requires relative path information. Full paths are not supported.

See Also

Reference

FtpWebRequest
FtpWebResponse
System.Net
WebException