0

My windows application is creating a xml file and adding data to it using XElement. Is there any way i can create this file in D:/ directly rather than the project bin folder(default). I want a web service to access this xml file to perform some function. So in that case i want it in some generic folder whenever this application is run on any system.

the code used to create and update the xml

x = new XElement("Data");
x.Add(new XElement("DataClass",
      new XElement("pathI", txt_input.Text),
      new XElement("pathO", txt_Output.Text),
      new XElement("prefix", txt_prefix.Text),
      new XElement("frequency", Convert.ToInt32(txt_freq.Text))));
x.Save("Data.xml");
abatishchev
  • 98,240
  • 88
  • 296
  • 433
user2038650
  • 73
  • 1
  • 10
  • Your code runs fine for me, the file gets created in the bin\debug folder. YOu might want to try `x.Save("Path to file" + "data.xml");` – Ravi Y Feb 11 '13 at 05:26

1 Answers1

3

Have you tried (at the end where you specify the file name):

x.Save(@"D:\DirectoryName\Data.xml");
Dimitar Dimitrov
  • 14,868
  • 8
  • 51
  • 79