将 XmlDocument 保存到 Azure Blob 存储,内容读取'System.Xml.XmlDocument'



我正在使用XmlDocument对象。当我将 xml 文件保存到 Azure blob 存储时,它成功了。但是当我尝试从 Azure 下载它时,内容只显示"System.Xml.XmlDocument"。我做错了什么?

这是我的代码:

XmlDocument doc = new XmlDocument();
// ...content of doc omitted for brevity
using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(doc.ToString())))
{
try
{
log.Info("Attempting to save file " + filename + " to: " + containerName);
blob.UploadFromStream(stream);
}
catch (Exception ex)
{
log.Error("Error uploading file. " + ex.Message + " " + ex.InnerException);
};
}

doc.ToString(( 只返回对象的类型名称。

你想要 OuterXml

最新更新