我有以下网络服务来使用fineupload上传文件
public class UploadHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var svc = new DropzoneService();
var request = context.Request;
var formUpload = request.Files.Count > 0;
var xFileName = request.Headers["X-File-Name"];
var qqFile = request["qqfile"];
var dzid = request.Params["dzid"].ToString().Replace(",", String.Empty);
var rootid = request.Params["rootid"].ToString().Replace(",", String.Empty);
var formFilename = formUpload ? request.Files[0].FileName : null;
var filename = xFileName ?? qqFile ?? formFilename;
var inputStream = formUpload ? request.Files[0].InputStream : request.InputStream;
var filePath = Path.Combine(context.Server.MapPath("~/App_Data/Queue"), filename);
using (var fileStream = File.OpenWrite(filePath))
{
inputStream.CopyTo(fileStream);
}
svc.AddFile(filePath, Int32.Parse(dzid), Int32.Parse(rootid));
context.Response.ContentType = "application/json";
context.Response.Write("{\"success\":true}");
}
public bool IsReusable
{
get { return true; }
}
}
它在除 Internet Explorer 8 和 9 之外的所有浏览器中都运行良好,但在 Internet Explorer 10 中运行良好。
这是异常 IO Exception The process could not access file C:\Users\user\Desktop\file.pdf 因为它正在被另一个进程使用。(瑞典语翻译的例外)