由于需要做在线更新,请问如何实现从服务器上将文件拷贝下来。要求通过两种方式,第一种直接利用file uri 来进行copy。另一种利用http uri来进行copy。主要是做如何通过Http来拷贝。最好利用WCF与服务器通信。
请大侠赐教,不胜感激。

解决方案 »

  1.   

    没用过WCF,我一般用HttpRequest或WebClient。
      

  2.   

    你的意思是想,将目标网页内容获取下来吗?如果是可以这样
      Try
                builder = New StringBuilder
                Dim uri As New Uri(Me.txtURL.Text)
                builder.Append("AbsolutePath:" & uri.AbsolutePath & ControlChars.CrLf)
                builder.Append("AbsoluteUri:" & uri.AbsoluteUri & ControlChars.CrLf)
                builder.Append("Host:" & uri.Host & ControlChars.CrLf)
                builder.Append("HostNameType:" & uri.HostNameType.ToString() & ControlChars.CrLf)
                builder.Append("LocalPath:" & uri.LocalPath & ControlChars.CrLf)
                builder.Append("PathAndQuery:" & uri.PathAndQuery & ControlChars.CrLf)
                builder.Append("Port:" & uri.Port & ControlChars.CrLf)
                builder.Append("Query:" & uri.Query & ControlChars.CrLf)
                builder.Append("Scheme:" & uri.Scheme)
                Dim request As WebRequest = WebRequest.Create(uri)
                Dim response As WebResponse = request.GetResponse()
                builder = New StringBuilder
                builder.Append("Request type:" & request.GetType().ToString() & ControlChars.CrLf)
                builder.Append("Response type:" & response.GetType().ToString() & ControlChars.CrLf)
                builder.Append("Content length:" & response.ContentLength & "bytes" & ControlChars.CrLf)
                builder.Append("Content type:" & response.ContentType & ControlChars.CrLf)
                builder.Append("Get HTML code successful! Time:" & DateTime.Now.ToString() & Environment.NewLine & Environment.NewLine)
                Dim stream As Stream = response.GetResponseStream()
                Dim reader As New StreamReader(stream, System.Text.Encoding.Default)
                Dim data As String = reader.ReadToEnd()
                reader.Close()
                stream.Close()
                Me.txtHTML.Text = data
                Me.txtResult.Text &= builder.ToString()
                getCW = True
            Catch ex As Exception
                builder = New StringBuilder()
                builder.Append("获取远程Web代码失败:" & ex.Message)
                builder.Append(" 时间:" & DateTime.Now.ToString())
                builder.Append(Environment.NewLine)
                builder.Append(Environment.NewLine)
                Me.txtResult.Text &= builder.ToString()
                getCW = False
            End Try如果你需要清楚HTML代码 只保留网页内容可以用这个正则表达式来过滤<\/*[^<>]*>
      

  3.   

    可以 使用 微软的 智能客户端http://dev.rdxx.com/NET/WindowsForms/2005-7/27/120622196_3.shtml
      

  4.   

    roki_chen ,不是这样的,就相当于一个cs结构的在线更新系统,下载文件包
      

  5.   

    --参考:
    http://blog.csdn.net/zlp321002/archive/2006/10/31/1359316.aspx
      

  6.   

    storm0912() ( ) 信誉:100    Blog   加为好友  2007-05-18 08:20:13  得分: 0  
     
     
       顶下,做过在先更新的高手帮忙回答下。
      
    ---------------------------------------------------------
    我就是用WebClient来做在线更新的。其实在这个方案中WCF并不是很好的解决方案。
      

  7.   

    写过一个类似的程序,实现局域网更新程序(HTTP一样),如果需要请给我发邮件索取。
    [email protected]