Solved

Copying a file

Posted on 2004-08-26
4
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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
ado.net AddWithValue when using IN condition 7 45
Problem to copy file 14 89
c#, case, if 4 37
Put File 6 36
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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