Hello all,
In my program I have to create a back up file whenevr a particular class is called.
Suppose class MyClass.cs creats a xml file(c:\test.xml) after serialization. when this class is called next time it first checks whether file(c:\test.xml) exist, if yes, take a back up(c:\test.xml.bak) and delete original file and then create new file(c:\test.xml) after serialization. This class can be called any number of times and back up file will be overwritten every time.
I tried with File.Copy() but it works only for first time,second time onwards it throws file(c:\test.xml.bak) allready exist.
Please help.
Thank you

1 answers
Instead of using File.Copy(source, dest), use File.Copy(source, dest, true).
This should then overwrite 'dest' if it already exists.
answered one year ago by:
17279
51
Thank you Vulpes..