I have a button, that button saves XML files, those XML files consist of files from a certain Data Set, How can i use that same button to copy the files listed, and paste them in a different directory.
Code for my button:
private void buttonSaveXML_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Filter = "XML Files|*.xml";
saveFile.Title = "Save a Xml File";
saveFile.InitialDirectory = @"C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\fxo\NewVersion";
saveFile.ShowDialog();
if (saveFile.FileName != "")
{
FileStream fs = (FileStream)saveFile.OpenFile();
dsVersions.WriteXml(fs);
}
Edit: I need to incorporate a code with this button that will copy and paste ALL the files in a dataGrid and be able to save an xml file while doing so.
You can use the FileSystem.CopyFile Method to do the job.