C# 我可以使用body.insertFileFromBase64 fromBase64吗?字符串来自文档文件而不是docx

C# 我可以使用body.insertFileFromBase64 fromBase64吗?字符串来自文档文件而不是docx,c#,ms-word,office365,office-js,C#,Ms Word,Office365,Office Js,我有webservice,它读取.doc或.docx,并通过ajax将其发送到我的插件中 这是web服务的代码 public string ReadDocument(string path) { FileStream fsStream = null; BinaryReader objReader = null; try { ////////////

我有webservice,它读取.doc或.docx,并通过ajax将其发送到我的插件中 这是web服务的代码

public string ReadDocument(string path)
        {

            FileStream fsStream = null;
            BinaryReader objReader = null;
            try
            {


                ////////////////////////

                // Now, read binary file
                //path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Copy.docx";
                fsStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                byte[] fileContent = new byte[fsStream.Length];
                objReader = new BinaryReader(fsStream);
                objReader.Read(fileContent, 0, fileContent.Length);
                //toRet.FileContent = fileContent;
                //toRet.FileName = "Test.doc";
                string StrBase64 = Convert.ToBase64String(fileContent);
                string _Document = StrBase64 ;
                return _Document;
                // FlushResponse(_Document, "application/pdf");
            }
            catch (Exception ex)
            {
                // FlushResponse("error");
                return "Error " + ex.Message;
            }
            finally
            {
                if (objReader != null) objReader.Close();
                if (fsStream != null) fsStream.Close();
            }
        }
当我的Base64String来自.docx时,我的body.insertFileFromBase64有问题,但当Base64String来自.doc时,它不工作 这是我插件中的代码我发送结果参数它是Base64String来自ajax

function InsertDocument(result) {
    Word.run(function (context) {

        // Create a proxy object for the document body.
        var body = context.document.body;
        body.clear();
        // Queue a commmand to insert base64 encoded .docx at the beginning of the content body.
        // You will need to implement getBase64() to pass in a string of a base64 encoded docx file.
        body.insertFileFromBase64(result, Word.InsertLocation.start);

        // Synchronize the document state by executing the queued commands,
        // and return a promise to indicate task completion.
        return context.sync().then(function () {
            console.log('Added base64 encoded text to the beginning of the document body.');
            $("#loading").hide();
        });
    })
我可以通过office.js或任何其他函数将.doc插入office 2016吗?方法的参考意味着第一个参数必须是docx文件:

需要base64文件字符串。.docx文件的base64编码内容


.

您能告诉我们您到底想做什么吗?我编辑了我的问题,请参见否。只支持docx。这里的字符串是Base64编码的OOXML。