View Single Post
Join Date: Jan 2009
Posts: 10
Reputation: No Pain No Gain is an unknown quantity at this point 
Solved Threads: 0
No Pain No Gain No Pain No Gain is offline Offline
Newbie Poster

Check a file exists on a website

 
0
  #1
Jan 12th, 2009
Currently my users download a database outside my app then from within it they can add the database to their main database. Now I want to have the app download and add the database all at once.

If I change the file extension to .txt the code below downloads the database as a text file but saves it as a mdb.

Dim strURL As String
Dim bData() As Byte ' Data variable
Dim intFile As Integer ' FreeFile variable

strURL = "http://www.asite/update1.txt"
intFile = FreeFile()
bData() = Inet1.OpenURL(strURL, icByteArray)
Open App.Path & "\update1.mdb" For Binary Access Write As #intFile
Put #intFile, , bData()
Close #intFile

But how can I check that the file exists on my site?

If the file doesn't exist, i.e. I haven't added the update to my site yet, the code still creates an update1.mdb that is really a text file that starts:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>The page cannot be found</TITLE>
Reply With Quote