我有一个专门放office文档的虚拟文件夹:www.xxx.com/file/,我在web(officedoc)项目中用window.open('www.xxx.com/file/test.xls','docpage','fullscreen=no,location=no,menubar=yes,..........)但是在标题栏和转到中有指向这个链接的地址www.xxx.com/file/test.xls.我想实现打开虚拟目录file中的文档,而不暴露我的链接,以免别人直接在地址栏中输入。用框架又不能打印,请问有什么好的解决方法??文档和项目是两个不同的虚拟目录。

解决方案 »

  1.   

    可以用StreamReader等读文件再输出
      

  2.   

    Dim file As String = Server.MapPath("excel_exe\xgb.xls")
            Response.AddHeader("content-disposition", "attachment;filename=" + "xgb.xls")
            Response.ContentType = "application/octet-stream"
            Response.WriteFile(file)
            Response.End()
      

  3.   

    1.可否采用地址加密的技术?地址可以记录在一XML文件中或者数据库2.采用流的方式读取文件3.^_^,可以屏蔽掉地址栏,防止用户看见,没有谁有多大的兴趣来象你说的那样操作的
      

  4.   

    可以用StreamReader等读文件再输出
    ====================================
    赞成!
      

  5.   

    同意老孟
    不过读出来输出是有点麻烦
    顺便给你一个读数据和写数据代码:
    读:
    StringBuilder htmltext=new StringBuilder();
    try 
    {
    StreamReader sr = new StreamReader("d:\\qiye1.htm",System.Text.Encoding.GetEncoding("gb2312"));

    String line;
    while ((line = sr.ReadLine()) != null) 
    {
    htmltext.Append(line);
    }
    sr.Close();

    }
    catch 
    {
    Response.Write("<Script>alert('读取文件错误')</Script>");
    }
    写:
    try
    {
    string path=Server.MapPath("../"+Session["diqu"].ToString()+"/"+Session["shixian"].ToString()+"/"+Session["username"].ToString()+"/qy2.html");
    StreamWriter sw=new StreamWriter(path,false,System.Text.Encoding.GetEncoding("gb2312"));
    sw.WriteLine(htmltext);
    sw.Flush();
    sw.Close();

    }
    catch(Exception ex)
    {
    Response.Write (ex.Message);
    }
    代码请自己修改
      

  6.   

    同意 robert2004(haha) 的方法。