I can't understand where problem is, despite the fact, that this code pretty easy.
I have such function:
public void WriteToDoc(string path)
{
XDocument doc = new XDocument(new XElement("General parameters",
new XElement("num_path", num_path.Text),
new XElement("Gen_Peroid", Gen_Peroid.Text),
new XElement("Alg_Perioad", Alg_Perioad.Text))
);
doc.Save(path); // here he gives that exception
}
num_path.Text
, Gen_Peroid.Text
and Alg_Perioad.Text
are string
.
This is how I use this function:
File.Create(@"C:\ProgramData\RadiolocationQ\Q.xml");
WriteToDoc(@"C:\ProgramData\RadiolocationQ\Q.xml");
It creates file, but nothing was written in that file. So the exact error System.IO.IOException
error, The process cannot access the file because it is being used by another process. How is it possible to get such error?