Preeti
Preeti

Reputation: 1386

How to save one file from one path to another path? Without removing file from original path using C#

I want to save one file from one path to another path.

Eg:

Original path : C:\File.txt

New path : D:\Folder\File.txt

Can i use:

File.Move("C:\File.txt", "D:\Folder\File.txt");

But i think this will remove file from original path. (C#)

Upvotes: 0

Views: 3306

Answers (7)

Emrah GOZCU
Emrah GOZCU

Reputation: 336

Just like this below...

System.IO.File.Copy(sourceFileName, destFileName);

Upvotes: 1

rahul
rahul

Reputation: 187050

You can use

File.Copy Method

Copies an existing file to a new file.

How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)

Upvotes: 2

ChrisF
ChrisF

Reputation: 137148

Try File.Copy instead.

Upvotes: 1

Janis Veinbergs
Janis Veinbergs

Reputation: 6988

Then you could use File.Copy.

Upvotes: 1

Marc Gravell
Marc Gravell

Reputation: 1062855

Try File.Copy, i.e.

File.Copy(@"C:\File.txt", @"D:\Folder\File.txt");

Upvotes: 5

Matt Lacey
Matt Lacey

Reputation: 65556

Have you tried File.Copy ?

Upvotes: 1

J. Random Coder
J. Random Coder

Reputation: 1342

Have you tried File.Copy(@"C:\File.txt", @"D:\Folder\File.txt");?

Upvotes: 1

Related Questions