c# .net

How to check Exists condition for file in asp.net?

How to check Exists condition for file in asp.net? , someone asked me to explain?

In this article I will explain how to check Exists condition for file in asp.net. If you need to delete the file before that you can check the file is exists or not. Sometimes the file is not present if you want to delete the file it may lead to an error. The best way to follow before deleting the file.

 if (System.IO.File.Exists(Server.MapPath(item.GalleryPath)))
    {
      System.IO.File.Delete(Server.MapPath(item.GalleryPath));
    }

Post your comments / questions