Click here to Skip to main content
15,908,626 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The page having one image control and one button when i click on button

first it check that this image exist or not. for eg(path is "C:/abc/sun.jpeg") it works when we debugg from application. but when we deploy this application then it doest find that path .i.e C:/abc/sun.jpeg" it exit from their and go to else.
C#
if (File.Exists(fullpath))
{
      Page.ClientScript.RegisterStartupScript(GetType(), "Message.....", "alert('Image  found');", true);
}
else
{
    Page.ClientScript.RegisterStartupScript(GetType(), "Message.....", "alert('Image not found');", true);
    return;
}
Posted
Updated 4-Dec-12 17:48pm
v2

1 solution

First of all, you must include all the images into your project, prefreably into images folder. Then use Server.MapPath to find our the image existance. Server.MapPath return the physical path of the image file so that you can use it to verify the existance.
C#
string imgpath = Server.MapPath("~\images\yourimg.jpg");

if(System.IO.File.Exists(imgpath))
...
else
...
 
Share this answer
 
v2
Comments
Kashinath Patil 4-Dec-12 23:42pm    
i want to browse the file from specific folder
Sergey Alexandrovich Kryukov 5-Dec-12 0:30am    
And..?
--SA
Sergey Alexandrovich Kryukov 5-Dec-12 0:29am    
Agree, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900