System.Web.HttpException (0x80004005): 与远程主机通信时发生错误。错误代码是 0x800703E5。 ---> System.Runtime.InteropServices.COMException (0x800703E5): 重叠 I/O 操作在进行中。
public ActionResult JqUpToFile()
{
try
{
//HttpPostedFileBase requestFile = null;
//HttpFileCollection requestFile;
//if (Request.Files["userExcelFile"] != null)
//{
// requestFile = Request.Files["userExcelFile"];
//}
//获取orgId
//上传地址配置到Config
string ExcelPath = "/UpFile/UpToExcel/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MMdd") + "/";
string uploadPath = "";
uploadPath = FileUpUrl + ExcelPath;
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
foreach (string key in Request.Files) // 文件键
{
var uploadFile = Request.Files[key];
string oFileName = uploadFile.FileName;
string oExt = oFileName.Substring(oFileName.LastIndexOf('.'));
oFileName = oFileName.Remove(oFileName.Length - oExt.Length, oExt.Length);
//string filetype = oExt.Remove(0, 1);
string fileName = oFileName + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + oExt;
uploadFile.SaveAs(uploadPath + fileName);
var data = new
{
fileName = fileName,
filePath = ExcelPath + fileName,
};
return Ok(data);
}
return Ok();
}
catch (Exception e)
{
log.Info("上传文件异常:" + e.Message);
throw;
}
}
#endregion
找不到问题
上代码
– dudu 5年前@dudu: 本地测试没有问题,放到现有的win2012r2服务器上就出现上传失败,cpu 飙升20%多。
– 代码小六 5年前@代码小六: 提供的代码中并没有“与远程主机通信”
– dudu 5年前FileUpUrl这个参数从哪里来的,值是啥
– Rise-亟 5年前@Rise-亟: web config 配置的路径 服务器一个具体物理路径
– 代码小六 5年前