Copying a file

What's the easiest way to copy a file (in C#) from one directory to another?  The only thing I'll need to do in addition is to overwrite the original file automatically (no message box), since I'll be copying the file every 10 seconds, for hours on end.

Thanks.
ba272Asked:
Who is Participating?
 
gregoryyoungConnect With a Mentor Commented:
use ...

System.IO.File.Copy() it will have no issue with rewriting the file http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiofileclasscopytopic.asp
0
 
sohilmCommented:
if you are trying to archive something, that I would use System.IO.File.Move()

SohilM.
0
 
armoghanCommented:

FileInfo fileInfo = new FileInfo(@"d:\testfile.txt");
fileInfo.CopyTo(@"d:\testfile1.txt", true);  
0
 
armoghanCommented:
Instead of using Static method, a more object oriented way for cSharp programmers ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.