Question

I want to copy a file from A to B in C#. How do I do that?

Was it helpful?

Solution

The File.Copy method:

MSDN Link

OTHER TIPS

Without any error handling code:

File.Copy(path, path2);

Use the FileInfo class.

FileInfo fi = new FileInfo("a.txt");
fi.CopyTo("b.txt");

System.IO.File.Copy

This should work!

using System.IO;

...

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


File.Copy(path,outputPath);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top