Could someone advise of how can I save a file into Path.Combine
directory?
Please find some of my code below.
Creation of directory:
string wholesalePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), mainFolder, wholesaleFolder);
Directory.CreateDirectory(wholesalePath);
I have also specified a file name which should be used.
string fileName = "xmltest.xml";
Then I have re-created a "wholesalePath" to include file name:
wholesalePath = Path.Combine(wholesalePath, fileName);
Few simple lines of code that gets executed:
XmlDocument doc = new XmlDocument();
string oneLine = "some text";
doc.Load(new StringReader(oneLine));
doc.Save(fileName);
Console.WriteLine(doc);
The problem I am having is that when I use doc.Save(fileName)
then I am getting file in VisualStudio project directories which is wrong directory.
However when I am using doc.Save(wholesalePath)
then file that should be created "xmltest.xml" is actually created as another directory within "wholesalePath".
I would be grateful for any suggestions.