Two methods for downloading files using FTP in VB. NET

Source: Internet
Author: User
Tags ftp
 
. Net does not have a dedicated FTP class. We can call the FTP. EXE that comes with the system or the wininet. dll in win32 API to complete basic operations. I hope the following code can help you.
Method 1: Use ftp.exe to call it through the process Class.
Imports System. Diagnostics
...
Public Sub GetFileByCallFtp ()
'Define The Start information of ProcessStartInfo and Process.
Dim psi As New ProcessStartInfo
The path of 'ftp.exe is best placed in the configuration file.
Psi. FileName = "C: WINNTsystem32ftp.exe"
Psi. RedirectStandardInput = False
Psi. RedirectStandardOutput = True
'Indicates that the process is not started using the operating system Shell program.
Psi. UseShellExecute = False
'Command set file name. Note that the path cannot contain spaces.
Dim fileName As String = "Cftp.txt"
'-S: FileName indicates that the control command is read from the file.
Psi. Arguments = "-s:" + fileName
Dim proc As Process
Proc = Process. Start (psi)
'Wait for the process to complete the task
Proc. WaitForExit ()
'Output the result on the console
Console. WriteLine (proc. StandardOutput)
Console. ReadLine ()
End Sub
========================================================== ==============================================

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.