.Net determine if file actually exists

Larry Brister
Larry Brister used Ask the Experts™
on
I have a sub routing that pulls data out of SQL Server table

One of the rows returned is a file path to an image in the web sites sub folder .../customerimages/

How do I determine if the file actually exists
If it does set the ,net image path

If it does not
Show a default image?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Expert
Awarded 2016
Top Expert 2016
Commented:
Hi,

You need to use File.Exists Method.

Dim FilePath As String = "yourFilePath.extension"
Console.WriteLine(If(File.Exists(FilePath), "File exists.", "File does not exist."))

Open in new window


You can read more from Microsoft on this.
https://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx
Larry Bristersr. Developer

Author

Commented:
Perfect
Thanks

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