Solved

Copying a file

Posted on 2004-08-26
4
211 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:ba272
  • 2
4 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11906874
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
 
LVL 3

Expert Comment

by:sohilm
ID: 11907432
if you are trying to archive something, that I would use System.IO.File.Move()

SohilM.
0
 
LVL 18

Expert Comment

by:armoghan
ID: 11914070

FileInfo fileInfo = new FileInfo(@"d:\testfile.txt");
fileInfo.CopyTo(@"d:\testfile1.txt", true);  
0
 
LVL 18

Expert Comment

by:armoghan
ID: 11914124
Instead of using Static method, a more object oriented way for cSharp programmers ;)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# Gridview 1 64
Get distinct values from excel or comm seperated file 4 40
RegEx with optional part 4 52
Return array 3 19
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question