Author Topic: Checking whether file exists in C#?  (Read 766 times)

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 69
Checking whether file exists in C#?
« on: October 24, 2011, 12:34:14 pm »
The following code would check whether the file c:\log.txt exists or not. If exists, then deletes the file.


using System.IO;

string myfile = "c:\\log.txt"

if (File.Exists(myFile))
{
         File.Delete(myFile);
}

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1