Introduction
Just go through the code and you will come to know that how to copy or downloads the files from FTP server to your local server/machines by using VB.Net Code
Background
Manuallyu copying the code from FTP server to local server is always a fun but the same is cumbersum job if gone through the code.........
Using the code
This is my one of the most beautiful work to copy multiple files from any FTP server to your desire folder or server........ Just go through the code and experience the beauty of it...
//
// Any source code blocks look like this
//
Dim oScript, oFileSys, objFSO, fileSearchObj, fileNameList, fileName, fileNameArray
Dim tempFileName As String
Try
Dim ftp_address As String = "ftp.XYZ.com" Dim ftp_username As String = "username" Dim ftp_password As String = "passwd"
fileSearchObj = CreateObject("Scripting.FileSystemObject")
fileNameArray = fileSearchObj.GetFolder("C:\ftpDownload\")
fileNameList = fileNameArray.files
For Each fileName In fileNameList
tempFileName = fileName.name
Dim objTextFile
Dim strFTPFileName As String = ""
strFTPFileName = "C:\ftpCommand.ftp"
objTextFile = objFSO.CreateTextFile(strFTPFileName, True)
objTextFile.WriteLine("open " & ftp_address) objTextFile.WriteLine(ftp_username) objTextFile.WriteLine(ftp_password) objTextFile.WriteLine("cd tempFolder") objTextFile.WriteLine("lcd C:\ftpDownload")
objTextFile.WriteLine("delete " & tempFileName) objTextFile.WriteLine("y") objTextFile.WriteLine("bye")
objTextFile.Close()
objTextFile = Nothing
Dim strCMD As String
strCMD = "ftp.exe -i -s: C:\ftpCommand.ftp"
Dim strTempFile As String
strTempFile = "C:\ftpOutput.txt"
Call oScript.Run("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True)
Next
Catch ex As Exception
End Try
<pre>You can use the desire desination folder instead of harc-coded C:\ drive
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here