网页浏览文件

/// <summary>     /// 查看     /// </summary>     /// <param name="sender"></param>     /// <param name="e"></param>     protected override void btnView_Click(object sender, EventArgs e)     {         string ids = this.hidKey.Value;         string[] queryArray = ids.Split('_');

        string bureauCode = queryArray[0];         string deptCode = queryArray[1];

        int iPlanNo = 0;         int.TryParse(queryArray[2], out iPlanNo);

        string filePath = bll.GetFilePathByCondition(bureauCode, deptCode, iPlanNo);

        string localPath = HttpRuntime.AppDomainAppPath.ToString();         string inputPath = localPath + filePath.Replace("~", "");

        if (!File.Exists(inputPath))         {             ShowMessage("error", "文件查看失败!该文件可能已被删除!");             return;         }

        string extension = System.IO.Path.GetExtension(filePath);         if (extension.Equals(".doc", StringComparison.OrdinalIgnoreCase))         {             WordPreview.Priview(this, inputPath, localPath);         }         else if (extension.Equals(".txt", StringComparison.OrdinalIgnoreCase))         {             TextFilePreview.Preview(this, inputPath);         }         else if (extension.Equals(".pdf", StringComparison.OrdinalIgnoreCase))         {             PDFPreview.Priview(this, inputPath);         }         else if (extension.Equals(".xlsx", StringComparison.OrdinalIgnoreCase))         {             ExcelPreview.Priview(this, inputPath, localPath);         }         if (extension.Equals(".docx", StringComparison.OrdinalIgnoreCase))         {             WordPreview.Priview(this, inputPath, localPath);         }

    }

posted @ 2016-12-05 17:18  佳序  阅读(228)  评论(0编辑  收藏  举报