devxlogo

Verify Whether a File Exists From ASP

Verify Whether a File Exists From ASP

Question:
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?

Answer:

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

See also  Small Business Strategies with Venmo
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist