web file exisits on web server?

stephenwilde
stephenwilde used Ask the Experts™
on
Hi

Have website built in .net c# and the code behind creates an image on page from a database reference.

The problem is I want to check the file exisits on the web server before I place the image on the page bit cannot find how due to path references of server v local path v full path reference - any help please?

Rgds
stephen
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Assuming you have virtual path of the image... you can use Server.MapPath(<<your relative path>>) to get the location on the physical drive. Then you can use System.IO.File.Exists method to verify if the image exists on the server.

-Ajitha

Author

Commented:
Thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial