I have a file upload code that works for chrome but throws the following error for IE.
"IOException: The process cannot access the file 'path\filename' because it is being used by another process. System.IO.__Error.WinIOError(int errorCode, string maybeFullPath) System.IO.FileStream.Init(string path, FileMode mode, FileAccess access, int rights, bool useRights, FileShare share, int bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost) System.IO.FileStream..ctor(string path, FileMode mode, FileAccess access, FileShare share) System.IO.File.OpenWrite(string path) RES.Controllers.DataHandling.DataUploadController+d__5.MoveNext() in DataUploadController.cs +
Controller action method below:
public async Task<IActionResult> Upload(UploadedData data)
{
var filename=string.Empty;
if (ModelState.IsValid)
{
var file = data.File;
var parsedContentDisposition =
ContentDispositionHeaderValue.Parse(file.ContentDisposition);
filename = Path.Combine(_hostingEnvironment.ContentRootPath,
"UplaodedFiles", parsedContentDisposition.FileName.Trim('"'));
using (var stream = System.IO.File.OpenWrite(filename))
{
await file.CopyToAsync(stream);
}
}
}
View model below:
public class UploadedData
{
public IFormFile File { get; set; }
}
I can imagine that there is nothing wrong with the code since it works for Chrome. Does anyone have any idea what the problem is with IE?
filename
? Please show the complete[HttpPost] Upload
method. – jAC