you first need to get the path from server.mappath() method like in the below example
Dim strImageLocation As String = "~/Images/photo/" + strItemCode + ".jpg"
Dim strActualImagePath As String = Server.MapPath(strImageLocation) Dim imgBtnImage As ImageButton = e.Item.FindControl("imgBtnImage") imgBtnImage.ImageUrl = strImageLocation
Dim myfile As New FileInfo(strActualImagePath) If myfile.Exists() Then
syedyaserahm...
Member
209 Points
200 Posts
checking file exits in the absolute path
Sep 29, 2011 05:41 AM|LINK
Dear friends,
how can i check if the file exist in the absolute path.
for example i have images in the absolute path from which i have to check if the image exits
I can do it from FILE.EXIST(path)
this method is not working for absolute path, even if the file exits its is showing the file doesnt exist.
is there any method to do this.
bhupalb
Participant
777 Points
160 Posts
Re: checking file exits in the absolute path
Sep 29, 2011 06:09 AM|LINK
File.Exists() will work for the absolute path in any whare
can give that path then i can tell u the problem
and you are checking in the web application
is it?
if (System.IO.File.Exists(@"D:\My Tasks\GoogleVis.txt"))
{
// }
like this it is working fine for me
any doubut post me reply then we can try to solv
if it is helpful mark it as answer
bhupal
syedyaserahm...
Member
209 Points
200 Posts
Re: checking file exits in the absolute path
Sep 29, 2011 06:44 AM|LINK
my path would be "~/Images/photo/123.jpg"
I need to check this image in the location
syedyaserahm...
Member
209 Points
200 Posts
Re: checking file exits in the absolute path
Oct 04, 2011 10:33 AM|LINK
you first need to get the path from server.mappath() method like in the below example