上传代码:第二版
If Connections.Contains("Conn_Source") Then
Connections.Delete("Conn_Source") '删除数据源
End If
Connections.Add("Conn_Source", GetConfigValue("Conn", "Error")) '新增外部数据源
Dim bbh As Date = Date.Now
'------------------------ftp服务器
Dim ftp1 As new ftpclient
ftp1.host=""
ftp1.Account = ""
ftp1.password = ""
'---------------------远程服务器
Dim dt As datatable
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Select 文件路径,文件校验码 from updates"
dt = cmd.ExecuteReader()
Dim ftp_jym As String = dt.GetComboListString("文件校验码")
'==========================
Dim i As Integer = 1
Dim dirs,dirys As New List(Of String) '目录树-数组
Dim gml As String = "\Publish"
dirs.Add(gml) '根目录
Do
For Each dirx As String In dirs '遍历获取目录-数组
For Each dir2 As String In FileSys.GetDirectories(dirx) '当前目录下所有目录
If dirs.Contains(dir2) = False Then
dirys.Add(dir2) '遍历当前目录,将目录列表添加至临时数组
End If
Next
Next
For Each b As String In dirys
If dirs.Contains(b) = False Then
dirs.add(b) '将目录临时数组,添加至dirs数组中.
End If
Next
dirys.Clear
i += i
Loop While i <= 1000
For Each dir As String In dirs
Dim dirname As String = dir
dirname = dirname.Replace(gml,"")
dirname = dirname.Replace("\","/")
If ftp1.DirectoryExists("../kangc" & dirname) = False Then '如果不存在目录,创建目录
ftp1.MakeDir("kangc" & dirname) '则创建目录
End If
For Each File As String In FileSys.GetFiles(dir)
Dim xy As String = File.Replace(gml,"")
xy = xy.Replace("\","/")
Dim jym As String = CRCCheckFile(File) '校验码
If ftp_jym.Contains(jym) = False Then
ftp1.Upload(file,"../kangc" & xy,True) '先上传文件
cmd.CommandText = "INSERT INTO updates(版本号,文件路径,文件校验码) VALUES('" & bbh & "','" & xy & "','" & jym & "')"
cmd.ExecuteNonQuery
End If
Next
Next
Output.Show((Date.now - bbh).Totalseconds)
[此贴子已经被作者于2010-10-19 23:49:06编辑过]