shanthiram
shanthiram

Reputation: 219

Copy one Xml Document contents into another one in C#

I am trying to copy contents of one xml file into another xml file. I found many examples where copying nodes is done but could not find how to just copy all the content.

Is this possible at all? If so can you please provide some direction.

Thanks

Edit: I want to create this new xml file in the location dynamically supplied by the application's text box.

Thanks again.

Upvotes: 1

Views: 6055

Answers (3)

Toby
Toby

Reputation: 7544

Is File.Copy() what you're looking for?

Upvotes: 1

Todd Richardson
Todd Richardson

Reputation: 1129

As a file:

string sourcefile = "somefile.xml";
string destinationfile = "anotherFile.xml";
System.IO.File.Copy(sourcefile, destinationfile);

Upvotes: 3

Tim Robinson
Tim Robinson

Reputation: 54734

If you want to replace one XML file with another, why not use File.Copy?

Upvotes: 5

Related Questions