【问题标题】:Saving XmlDocument to Azure Blob Storage, content reads 'System.Xml.XmlDocument'将 XmlDocument 保存到 Azure Blob 存储,内容为“System.Xml.XmlDocument”
【发布时间】:2019-02-17 17:10:17
【问题描述】:

我正在使用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);
    };
}

【问题讨论】:

    标签: c# xml azure-blob-storage


    【解决方案1】:

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

    你想要 OuterXml

    【讨论】:

    • 天啊!不错的收获!
    猜你喜欢
    • 2021-03-19
    • 1970-01-01
    • 2020-08-25
    • 2021-09-20
    • 2016-12-07
    • 2016-08-30
    • 1970-01-01
    • 2021-12-08
    • 2021-08-22
    相关资源
    最近更新 更多