views:

147

answers:

2

I am saving an XMLDocument object to disk using the Save (string) function. When I do this I get a "Could not find a par of the path" error.

I have tried passing the characters as "&", "&", "%26", "\26", and "\38". What am I missing? Note that I am not talking about the content of the file -- but the filename.

Dim todocument As New Xml.XmlDocument
todocument.LoadXml(fromXml.OuterXml)
todocument.Save(toPath)
A: 

& (ampersands) are perfectly legal to put in a filename/path. 2 things to check.

  1. make sure the destination folder is there
  2. try saving it to a filestream object instead.
Al W
Going to give you credit here for the 'destination folder' being missing... really my \'s were encoded when they weren't supposed to be throwing my whole path off.
pc1oad1etter
A: 

My particular problem was not that the &'s weren't encoded -- my '\'s in the path were encoded and they weren't supposed to be.

pc1oad1etter