Hello,
I am using LINQ to retrieve data from the DataBase, the variable name relative to link is "service".
the upDocument is the Id of a FileUpload control.
The objective is to delete the old file, before uploading a new one. This is the code i came up with:
if ((service.image_url != null || service.image_url != "") &&
(upDocument.FileName.Length != 0 || upDocument.PostedFile.ToString() != ""))
{
if (File.Exists(System.Web.HttpContext.Current.Server.MapPath(service.image_url)))
{
File.Delete(System.Web.HttpContext.Current.Server.MapPath(service.image_url));
}
}
The problem that I have, is that althought nothing is being loaded to the FileUpload the file is still being deleted. I made a breakpoint and checked it out... and contraty to what i was expecting the FileName.Length is not 0, and the postedFile.ToString() is not "".
How can i make a correct validation?
Thanks in advance.