Como copiar um ficheiro Em C#

Quero copiar um ficheiro de A Para B Em C#. Como faço isso?

Author: Sumon Banerjee, 2008-08-21

5 answers

O Ficheiro.Método de cópia:

Ligação MSDN

 12
Author: Shaun Austin, 2008-08-22 10:03:34

Sem qualquer código de manipulação de erros:

File.Copy(path, path2);
 14
Author: Corey, 2008-08-21 13:45:56

Use a classe FileInfo.

FileInfo fi = new FileInfo("a.txt");
fi.CopyTo("b.txt");
 2
Author: Eric Z Beard, 2008-08-21 13:45:44

System. IO. File. Copy

 1
Author: Jedi Master Spooky, 2008-08-21 13:45:42
Isto deve funcionar!
using System.IO;

...

var path = //your current filePath
var outputPath = //the directory where you want your (.txt) file


File.Copy(path,outputPath);
 1
Author: Stan van de Bovenkamp, 2018-09-27 07:02:05