Delete a file if exist

image_pdfimage_print
   
 
using System.IO;


  /// <summary>
  /// Static methods extending the <see cref="File"/> class.
  /// </summary>
  public static class FileExtension
  {
    /// <summary>
    /// Deletes the specified <paramref name="file"/> if it exists.
    /// </summary>
    /// <param name="file">The file to delete.</param>
    public static void DeleteIfExists(string file)
    {
      if (File.Exists(file))
      {
        File.Delete(file);
      }
    }
  }

   
     


This entry was posted in File Stream. Bookmark the permalink.