Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                String l_strTemplateName  = Request.QueryString[ConstString.QueryString.TEMPLATE_NAME];
                String l_strUrl           = Request.QueryString["URL"];
                String l_strExtension     = System.IO.Path.GetExtension(l_strUrl);
                String l_strAlias         = Request.QueryString["Alias"];
                String l_strTotalFileName = l_strAlias + l_strExtension;

                if (l_strTemplateName.Contains("新版"))
                {
                    l_strTemplateName = l_strTemplateName.Substring(2);
                }

                String downName = HttpUtility.UrlEncode(System.Text.UTF8Encoding.UTF8.GetBytes(l_strTotalFileName));

                long fileLength = MossObject.FileLength(l_strTemplateName, l_strUrl);

                //TODO:对于大附件的处理
                //小附件:直接使用WebService,返回Byte[]
                //大附件:将附件从MOSS库写入文件,保存到服务器端
                if (fileLength <= MossObject.middleFileSize * 1024 * 1024)
                {
                    Byte[] fileByte = MossObject.DownLoad(l_strTemplateName, l_strUrl);

                    Response.Buffer          = true;
                    Response.ContentType     = "application/octet-stream";
                    Response.ContentEncoding = System.Text.Encoding.Unicode;

                    Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", downName));
                    Response.BinaryWrite(fileByte);
                    Response.End();
                }
                else
                {
                    string tempFilePath = MossObject.DownLoad_New(l_strTemplateName, l_strUrl);

                    this.DownLoad_File(tempFilePath, downName);
                }
            }
        }