简体   繁体   English

用单词打开文档,没有路径

[英]Open document with word, without path

I'm searching how to open a document with word, without its path. 我正在搜索如何用word打开文档,但没有路径。

I get my document like this : 我得到这样的文件:

byte[] text = item.Doc;

The document comes directly from database. 该文档直接来自数据库。

I only found way to open with a path... So with my doc, I must open it, and then run saveAs of word application (choice between pdf, doc etc...). 我只找到了用路径打开的方法...因此,对于我的文档,我必须将其打开,然后运行word应用程序的saveAs(在pdf,doc等之间进行选择...)。

I can store it in a MemoryStream , but, what can I do with it next? 我可以将其存储在MemoryStream ,但是接下来该怎么办?

Found this How to open a file from Memory Stream , but not helping me. 找到了“ 如何从Memory Stream打开文件” ,但对我没有帮助。

try this 尝试这个

    Response.Clear();
    Response.Buffer = true;
    Response.ContentType = "application/ms-word";
    string fileName = "Test.doc";
    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
    StreamReader reader = new StreamReader(memoryStream, System.Text.Encoding.UTF8, true);
    string  strContents = reader.ReadToEnd();
    Reader.Close();
    Response.Write(strContents);
    Response.End();

--SJ --SJ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM