develope_AK
develope_AK

Reputation: 59

How to fix error The process cannot access the file 'D:\myfolder\myproject\ExcelFolder\myFile.xlsx' because it is being used by another process

When I tried to Upload my exel file it gives error.

CODE

[HttpPost]
public ActionResult myAction(HttpPostedFileBase file, FormCollection form) 
{       
    file.SaveAs(Server.MapPath("~/ExcelTemplates/" + file.FileName));
}

Upvotes: 0

Views: 687

Answers (2)

Prakash Mhasavekar
Prakash Mhasavekar

Reputation: 592

Kill EXCEL.exe process from task manager. I hope it will work for you.

Upvotes: 1

LazZiya
LazZiya

Reputation: 5729

Save the file with a new name, may be it is still handled by the browser if you have tried to upload before.

btw it is recommended to rename uploaded files and use the file name only for display purpose, see the docs here: https://learn.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-2.2

additionally you may see this file upload sample on GitHub using dropzone

Upvotes: 1

Related Questions