Code
Imports System.IO
Public Shared Sub UpLoadFTPBat(ByVal fileName As String, ByVal filePath As String)
Dim ftpServer As String = "cetbiserver"
Dim ftpUserName As String = "gi\ike_li"
Dim ftpPassWord As String = "ikeli123456"
Dim fileNamePath As String = filePath + fileName + ".xls"
Dim ftpFileName = filePath + "\" + fileName + ".ftp"
Dim sw As StreamWriter = New StreamWriter(ftpFileName, False)
sw.WriteLine("open" + ftpServer)
sw.WriteLine("user")
sw.WriteLine(ftpUserName)
sw.WriteLine(ftpPassWord)
sw.WriteLine("cd /scsTEST/")
sw.WriteLine("put " + fileNamePath)
sw.WriteLine("quit")
sw.Flush()
sw.Close()
Dim BatCommandLine As String = "ftp -v -n -i -s:" + ftpFileName
Dim ftpBatFileName As String = filePath + "\" + fileName + ".bat"
Dim sw2 As StreamWriter = New StreamWriter(ftpBatFileName, False)
sw2.WriteLine(BatCommandLine)
sw2.Close()
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
p.StartInfo.FileName = ftpBatFileName
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.Start()
p.WaitForExit()
Dim ftpOutPut As String = p.StandardOutput.ReadToEnd
p.Close()
Dim fileName_FtpLog = filePath + "\" + fileName + ".log"
Dim sw3 As StreamWriter = New StreamWriter(fileName_FtpLog, False)
sw3.WriteLine(ftpOutPut)
sw3.Flush()
sw3.Close()
End Sub