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

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top