示例
Try
Dim siteUri As New System.Uri("http://www.microsoft.com")
Dim webRequest As System.Net.WebRequest = _
System.Net.WebRequest.Create(siteUri)
webRequest.Proxy = New System.Net.WebProxy("YourProxySetting")
Dim webResponse As System.Net.WebResponse = webRequest.GetResponse()
Catch ex As Exception
' The Web request failed.
End Try
拷贝方式
Dim Source As String = "C:\Test.csv"
Dim Destination As String = "d:\ee.csv"
System.IO.File.Copy(Source, Destination, True)
另外一种方法,可以将ping后的结果保存到文件,然后判断文本文件中是否包含
Lost = 0,或者是否有Reply
Process.Start("ping 127.0.0.1 > c:\1.txt");
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Reply from 127.0.0.1: bytes=32 time<10ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms