Results 1 to 3 of 3

Thread: Check if remote file exists

  1. #1
    boon is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2007
    Posts
    2
    Reputation
    0

    Arrow Check if remote file exists

    Hi!
    I would like to note that I'm kind of new to vb.net , so don't be too harsh on me .

    I have a text file(boon.somekindofhost.com/file.txt) on a http host , I need to check if it exists , if it doesn't then
    execute myfunction() .
    How could i do that?
    The title was supposed to say "Check if remote file exists"

  2. #2
    JohnH's Avatar
    JohnH is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,612
    Reputation
    2739
    This seems to work:
    Code:
    Function WebFileExists(ByVal url As String) As Boolean
        Try
            Dim web As New Net.WebClient
            Dim s As IO.Stream = web.OpenRead(url)
            s.Close()
            Return True
        Catch ex As Exception
        End Try
        Return False
    End Function

  3. #3
    boon is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Jun 2007
    Posts
    2
    Reputation
    0

    Thumbs up Thanks!

    Thanks alot!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking