当前位置:编程学习 > C#/ASP.NET >>

求助 DSOframer 保存文件

我C#.NET开发的WEB程序中使用DSOframer进行word文档的操作,如果是新建一个word文件就可以了保存到服务器,但是如果打开一个已存在的文件再保存到服务器则保存的是一个空文件,一直找不到愿意,请大家帮忙!
打开已存在文件和保存文件的代码:
<script language="javascript" type="text/javascript"> 

         function show_word() {
               //document.all.MyOffice.CreateNew("Word.Document");//新建空白文档
               var file="../template/"+document.getElementById("HiddenField1").value+".doc";
               document.all.MyOffice.Open(file,false,"Word.Document","","");
               document.all.MyOffice.Titlebar=true;//隐藏/显示标题栏~
               document.all.MyOffice.Caption= "Word文档";//设置标题栏文字
               document.all.MyOffice.SetTrackRevisions(1);
        }
        
           function show_excel() {
               document.all.MyOffice.CreateNew("Excel.Sheet");//新建空白文档
               document.all.MyOffice.Titlebar=true;//隐藏/显示标题栏~
               document.all.MyOffice.Caption= "Excel文档";//设置标题栏文字
           }
           
           
           
           function save() {
           
           if(document.getElementById("ft_name").value=="")
           {
           alert("文件名不能为空!");
           show_word();
           }
           else
           {
            document.all.MyOffice.SetTrackRevisions(4);
            var file=document.getElementById("HiddenField1").value+".doc";
            document.all.MyOffice.HttpInit();

            document.all.MyOffice.HttpAddPostCurrFile("FileData", file);        
            var src = "./saveFile.aspx";
            var value=document.all.MyOffice.HttpPost(src); 
            document.getElementById("Button1").click();
            alert('保存成功!');
         }
        }
        </script>
后台保存文件的代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public partial class wf_fileTemplate_saveFile : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpFileCollection files = HttpContext.Current.Request.Files;
        if (files.Count > 0)
        {
            HttpPostedFile postedFile = files[0];
            string fileName, fileExtension;
            fileName = System.IO.Path.GetFileName(postedFile.FileName);
              我在这一步调试的时候发现postedFile有一个contentLength长度为0,不知道为什么无法获得页面上的文件
            if (fileName != "")
            {
                fileExtension = System.IO.Path.GetExtension(fileName);
                string value = "123";
                postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("../template/") + value + fileExtension);
                Response.Write(value);
                Response.End();
            }
        }
    }
}
web 调试
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,