01.
Dim
ServerName
As
String
=
"ftp.avchemical.com"
02.
03.
04.
Dim
UserName
As
String
=
"dmh6161450"
05.
06.
07.
Dim
UserPwd
As
String
=
"REg8fUlU"
08.
09.
10.
Dim
UploadFile1
As
String
=
"C:\Test BackUp\ConsumerDB.bak"
11.
12.
13.
Dim
ServerFile1
As
String
=
"/Test/Consumer.bak"
14.
15.
16.
17.
18.
19.
20.
Dim
FTPfile
As
String
=
"c:\Test BackUp\ftpcmd.txt"
21.
22.
23.
Dim
sb1
As
New
System.Text.StringBuilder
24.
25.
26.
27.
sb1.Append(UserName & vbCrLf)
28.
29.
30.
sb1.Append(UserPwd & vbCrLf)
31.
32.
33.
sb1.Append(
"put "
& UploadFile1 &
" "
& ServerFile1 & vbCrLf)
34.
35.
36.
sb1.Append(
"bye"
& vbCrLf)
37.
38.
39.
40.
Dim
fs1
As
System.IO.StreamWriter
41.
42.
43.
fs1 =
New
System.IO.StreamWriter(FTPfile)
44.
45.
46.
fs1.Write(sb1.ToString)
47.
48.
49.
fs1.Close()
50.
51.
52.
53.
54.
55.
56.
Dim
BATCHfile
As
String
=
"c:\temp\ftpbatch.bat"
57.
58.
59.
Dim
OutputFile
As
String
=
"c:\temp\ftpoutput.txt"
60.
61.
62.
Dim
sb2
As
New
System.Text.StringBuilder
63.
64.
65.
sb2.Append(
"ftp -s:"
& FTPfile &
" "
& ServerName &
" > "
& OutputFile & vbCrLf)
66.
67.
68.
sb2.Append(
"type NUL > "
& FTPfile & vbCrLf)
69.
70.
71.
sb2.Append(
"del "
& FTPfile & vbCrLf)
72.
73.
74.
75.
Dim
fs2
As
System.IO.StreamWriter
76.
77.
78.
fs2 =
New
System.IO.StreamWriter(BATCHfile)
79.
80.
81.
fs2.Write(sb2.ToString)
82.
83.
84.
fs2.Close()
85.
86.
87.
88.
89.
90.
91.
Dim
ProcID
As
Integer
92.
93.
94.
ProcID = Shell(BATCHfile, AppWinStyle.NormalFocus)
95.
96.
97.
98.