Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Check if image file exists before linking to Image object

Reply
Thread Tools

Check if image file exists before linking to Image object

 
 
Filip De Backer
Guest
Posts: n/a
 
      06-11-2004
Hi,

I know that the File object doens't work in asp.net, but how can I check if a file MyDog.jpg exists before I link it to the Image object in my web aplication.
I want to show NoPicture.jpg when the file doesn't exist.

I want to change the code to something I can use but I don't know what :

strFileName = "MyDog.jpg";
if (System.IO.File.Exists(strFileName))
{
imgPicture1.ImageUrl = strFileName;
}
else
{
imgPicture1.ImageUrl = "NoPicture.jpg";
}

thanks a lot

Filip
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check if a directory exists? folder.exists() does not work! Ulf Meinhardt Java 8 08-28-2009 12:26 PM
How to check if all *.jars in my CLASSPATH really exists? Automatic check (not manual) possible? Jason Stacy Java 2 04-27-2008 08:14 AM
finding if file exists or not in apache webdav server and if exists what is the mime type of it.... Totan Java 0 04-17-2006 05:13 AM
check if image or file exists Filip De Backer ASP .Net Web Controls 2 06-23-2005 12:33 PM
Can I check if an object exists? Randell D. Javascript 21 03-02-2005 08:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57