File IO error

falco

Member
Joined
Feb 13, 2003
Messages
22
Location
Ft. Lauderdale FL. USA
Can someone explain why I am getting the following build errors?

No overload for method File takes 1 arguments

System.IO.File does not contain a definition for CopyTo


Code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

File adofile = new File("C:\\dotNET Book\\Ch8_ADO.doc");

adofile.CopyTo("C:\\dotNETBook\\Sample\\Ch8_Backup.doc");
 
Its not working because there is no contructor on the File class, as it said. You cant just invent syntax like this. To copy a file, you use the static method of the File class:

C#:
System.IO.File.Copy("C:\\dotNET Book\\Ch8_ADO.doc", "C:\\dotNETBook\\Sample\\Ch8_Backup.doc");
 
Back
Top