I have this function that gets the fileData as a byte array and a file path. The error I am getting is when it tries to set the fileInfo in the code bewlo. It says \'Physica
I take it that your project is located at:
E:\WEBS\\webapp\
You should try and use relative references to your images e.g.
..\default\images\mains\myimage.jpg
Working:
string[] filesPath = Directory.GetFiles(Server.MapPath("~/txtPath/"));
foreach (string path in filesPath)
{
FileInfo fi = new FileInfo(path); //This Is Working
string LastAcceTime = fi.LastWriteTime; //Return Correct Value
}
Not Working:
string[] filesPath = Directory.GetFiles(Server.MapPath("~/txtPath/"));
foreach (string path in filesPath)
{
FileInfo fi = new FileInfo(Server.MapPath(path)); //This Is Worng
string LastAcceTime = fi.LastWriteTime; //Return 1/1/1601
}
Dont use Server.Mappath
twice
If you already have a physical path, it doesn't make sense to call Server.MapPath
.
You're calling MapPath
twice.