我正在使用XmlTextWriter並從加載其他服務的URL時出現錯誤。錯誤是「路徑中的非法字符」。我曾嘗試使用@「https://www.foo.com/foobar/rest-1/Data/Test?sel=GeneratedFrom&find=TS-01108&findin=Parent.Number」路徑c#中的非法字符 - XmlTextWriter
當我使用調試器進行檢查時,發現該值有引號,但我懷疑它可能是「?」,「=」,「&」或「。」。也許。
string URL = "https://www.foo.com/foobar/rest-1/Data/Test?sel=GeneratedFrom&find=TS-01108&findin=Parent.Number";
string XML_FILENAME = URL + ".xml";
WebResponse response = utils.GetRestResponse(URL);
if (response != null)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(XmlReader.Create(response.GetResponseStream()));
// Illegal characters in path happens here
XmlTextWriter writer = new XmlTextWriter(XML_FILENAME, null);
你需要一個文件,而不是一個網址。 – Xaruth