A Repasky

A Repasky

  • 1.9k
  • 231
  • 172.4k

Deleting an exiting file

Jul 5 2011 4:50 PM
My lead programmer wants me to use the code below to write out the records on a file.

The problem is that if the file is already existing them it does not delete the old file and create a new file and only appends.
I was doing it another way and he did not like it because it was like VB.
Is there way to check for an existing file and delete it with this "using" statement. I know this seem dumb, but that is what he wants.


      public static void Printweekly(string Output)
         using (StreamWriter weekly = new StreamWriter(Program.location + "\\" + Program.name + Program.weeklyEndDate + ".csv"true))
            weekly.WriteLine("{0}", Output);


Can anyone help? Thanks ahead of time.


Answers (8)