[解决办法] c#和vb.net差不多,把原理和方法看懂了不就行了吗 [解决办法] WebRequest的方法 用Dim request As HttpWebRequest = WebRequest.Create(下载地址) ' 找到下载的开始位置 If startPos > 0 Then request.AddRange(startPos) [解决办法] 我用的My.Computer.Network.DownloadFile 下载
Public Function DownLoadFiles(ByVal strUrl As String, ByVal strVer As String) Dim strFiles, strVFile, strCheckVer As String Dim a() '数组 Dim i As Int16 Try '比较版本号 strVFile = XmlR(strUrl & "\Update\update.xml", "Root", "Update", "Ver") strCheckVer = CheckVer(strVFile, strVer) '还有小于 Select Case strCheckVer.Trim Case "0" Return 0 : Exit Function Case "<" 'strver 小于从文本中取得版本号则更新 Case ">" Return 0 : Exit Function End Select ' My.Computer.Network.DownloadFile("http://www.cohowinery.com/downloads/WineList.txt", "C:\Documents and Settings\All Users\Documents\WineList.txt", False, 500) strFiles = XmlR(strUrl & "\Update\update.xml", "Root", "Update", "Files") a = Split(strFiles, ",") '文件中files项中不可含回车换行,如有则出现路径含非法字符错误 For i = 0 To a.Length - 1 If System.IO.File.Exists(Application.StartupPath & "\" & a(i)) = True Then System.IO.File.Move(Application.StartupPath & "\" & a(i), a(i) & ".old") '改名 My.Computer.Network.DownloadFile((strUrl & "\Update\" & a(i)), (Application.StartupPath & "\" & a(i))) '复制 System.IO.File.Delete(Application.StartupPath & "\" & a(i) & ".old") '删除备份 Else My.Computer.Network.DownloadFile(strUrl & "\Update\" & a(i), Application.StartupPath & "\" & a(i)) '复制 End If Next Return 1 Catch ex As Exception MessageBox.Show(ex.Message) : Return -1 End Try End Function