Simple FTP application under C # 2.0

Source: Internet
Author: User
Tags ftp

Introduced

Microsoft's. NET Framework 2.0 has increased support for FTP relative to 1.x. In the past, in order to meet my needs, I did not use a Third-party class library to achieve FTP functionality, but for the sake of reliability, it is better to use the. NET Framework analogy. My Code does not form a reusable class library, but it is easier to understand and meets your needs. It can upload, download, delete and other arbitrary functions. At the end of this article we will show you the simple code for FTP under. NET 2.0, which is in C #. Perhaps because this is the. NET new class, or the third party class library has been able to achieve your needs, the. NET 2.0 of this part of the class library has not received enough attention.

Background

As part of my work, I have used the FTP module, but I can only use it in. NET 1.1, so I can't delve into the implementation of. NET 2.0 FTP. But I believe that the support for FTP under NE 2.0 is very good.

Code

Don't forget to introduce namespaces

Using System.Net;

Using System.IO;

The following steps include a general procedure for using the FtpWebRequest class to implement FTP functionality

1, create a FtpWebRequest object, point to the FTP server URI

2, set the FTP implementation method (upload, download, etc.)

3. Set properties for FtpWebRequest objects (whether SSL is supported, binary transmissions are used, etc.)

4, Set login authentication (username, password)

5, the implementation of the request

6, receive the corresponding flow (if necessary)

7, if there is no open stream, then close the FTP request

The development of any FTP application requires a related FTP server and its configuration information. FtpWebRequest exposes some properties to set this information.

The next code example is the upload function

First, set a URI address, including the path and file name. This URI is used in the FtpWebRequest instance.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.