HTTP の場合は、HTTP HEAD メソッドを使用します。コンテンツ ヘッダーのみを返す点を除いて、GET メソッドと同様に動作します。ファイルが存在しない場合、サーバーは 404 ステータス コードを返す必要があります。それ以外の場合は、ファイルが存在すると見なすことができます (コンテンツ ヘッダーからそのサイズを取得することもできます)。
編集
次のコードを使用できます。
Public Function ResourceExists(location As Uri) As Boolean
If (Not String.Equals(location.Scheme, Uri.UriSchemeHttp, StringComparison.InvariantCultureIgnoreCase)) And (Not String.Equals(location.Scheme, Uri.UriSchemeHttps, StringComparison.InvariantCultureIgnoreCase)) Then
Throw New NotSupportedException("URI scheme is not supported")
End If
Dim request = Net.WebRequest.Create(location)
request.Method = "HEAD"
Try
Using response = request.GetResponse
Return DirectCast(response, Net.HttpWebResponse).StatusCode = Net.HttpStatusCode.OK
End Using
Catch ex As Net.WebException
Select Case DirectCast(ex.Response, Net.HttpWebResponse).StatusCode
Case Net.HttpStatusCode.NotFound
Return False
Case Else
Throw
End Select
End Try
End Function
使用法:
Dim itExists As Boolean = ResourceExists(New Uri("http://ccc-itgs2012.wikispaces.com/file/view/AP+Human+Geography+Gapminder.flv"))
これは呼び出し元のスレッドをロックするため、非同期メソッドにリファクタリングすることをお勧めします。