错误信息:文件“d:\201012110047138839434.xls”正由另一进程使用,因此该进程无法访问该文件。
源码:/// <summary>
        /// 保存到客户端
        /// </summary>
        /// <param name="MyPage"></param>
        /// <param name="ClientFileName"></param>
        /// <param name="filePath"></param>
        private void ClientSave(System.Web.UI.Page MyPage, string ClientFileName, string filePath)
        {
            MyPage.Response.ContentType = "Application/octet-stream";
            MyPage.Response.AppendHeader("Content-Disposition", "inline;filename=" + ClientFileName);            byte[] b = getByte(filePath); //确保该目录下有这个文件            //创建内存流,将该文件写入内存流中
            System.IO.MemoryStream m = new System.IO.MemoryStream(b);
            m.WriteTo(MyPage.Response.OutputStream);
            m.Close();
            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }
            MyPage.Response.End();
        }
        /// <summary>
        /// 将制定路径的文件转换成字节数组
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private byte[] getByte(string filePath)
        {
            ////EndExcelProcess();
            //Process[] myProcesses;
            //DateTime startTime;
            //myProcesses = Process.GetProcessesByName("Excel");            //foreach (Process myProcess in myProcesses)
            //{
            //    startTime = myProcess.StartTime;
            //    if (startTime > beforeTime && startTime < afterTime)
            //    {
            //        int i = 1;
            //        while (!myProcess.HasExited)
            //        {
            //            i++;
            //        }
            //        i++;
            //        while (true)
            //        {
            //            i++;
            //            if (i == 1000)
            //            {
            //                break;
            //            }            //        }
            //    }            //}            FileStream fs = File.OpenRead(filePath);//测试时此处出现问题,我加了以上注过的代码也不行
            byte[] UpFile = new byte[fs.Length];
            fs.Read(UpFile, 0, UpFile.Length);
            fs.Close();
            return UpFile;
        }