File Does Not Exist

G

Guest

i have very strange problem in a Directory C:\Images I'm checking if an image
is exist then copy it to other folder using following code:
if(FilePath.Trim().Length == 0)
return String.Empty;
string fileName = System.IO.Path.GetFileName(FilePath);
string path = Server.MapPath("images\\LogInPageImages") + "\\" + fileName;
if(System.IO.File.Exists(FilePath))
//here Exist return false though file exist in folder ...WHY?
System.IO.File.Copy(FilePath,path,true);
return @"images\LogInPageImages\" + fileName ;
 
G

Guest

get the value of the path and compare... just to be sure.
Also, if the user that IIS/ASP.Net is running under doesnt have permission
you will get a FALSE return.
 
N

Norman Yuan

This--> Server.MapPath("images\\LogInPageImages")
Should be -->Server.MapPath("images/LogInPageImages")

Note: in virtue path, you use "/", not "\" ("\\" in C#).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top