I am trying to access some PDF files in a database. I give the address of the file in the browser as an IP address. I am trying to create links for these files in a page. Before painting the link, I want to verify whether the link is valid and that the file exists. How can I do this in ASP?
Use the FileExists method of the FileSystemObject from ASP to check if the file exists.
Dim fs, strFileNameAndPathstrFileNameAndPath = Your file name' -- Use file name and path ' -- from the database. Remember to map it ' -- to the Web Server's point of view. ' -- Use Server.MapPath for help.Set fs = CreateObject("Scripting.FileSystemObject")If fs.FileExists(strFileNameAndPath) Then ' -- file existselse ' -- file does not existend if