如何在C#中使用StreamReader类将html保存为doc文件

时间:2018-12-25 08:44:43

标签: c# jquery

我正在尝试通过C#和jQuery将HTML页面保存为doc。它正在运行,但是保存后在html上显示的图像未显示doc。这是我的代码:

jQuery代码:

function submit() {
    var imageInByte = encodeURIComponent($('#cmpstamp').attr('src'));
    $.ajax({
            async: false,
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            url: "Agreement.aspx/submitAgreement",
            data: JSON.stringify({ AppId: getQueryString("appid"), agreement: $('.word-content').html()),
            dataType: 'json',
            success: function (data) {
                if (data.d == "Success") {
                    alert(data.d);
                }
            }
        })
}

C#代码:

[WebMethod]
public static string submitAgreement(string agreement, string AppId)
{          
    using (StreamWriter writer = new StreamWriter(HttpContext.Current.Server.MapPath("~/Documents/ApplicationFile/" + AppId + "/myagreement.doc"), true))
    {
        string output = agreement + str;                            
        writer.Write(output);
        writer.Close();
    }

    return "";
}

0 个答案:

没有答案