Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copying a file

Posted on 2004-08-26
4
Medium Priority
?
217 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 2000 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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 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