Copying A File by using FileInfo : File Copy « File Directory Stream « C# / CSharp Tutorial






using System;
using System.IO;

public class MainClass
{
  static void Main(string[] args)
  {
    FileInfo MyFile = new FileInfo(@"c:\Projects\Testing.txt");

    MyFile.Create();
    MyFile.CopyTo(@"c:\Folder\Testing.txt");

    //or
    MyFile.CopyTo(@"c:\Folder\Testing.txt", true);
  }
}








15.4.File Copy
15.4.1.Copy a file
15.4.2.Writing data: copying from one stream to another
15.4.3.Copying A File by using FileInfo