c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

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

| | ASP-NET , CSharp

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));
    }