Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS File Lock - The Process Cannot Access The File Because It Is Being Used By Another Process

Tags:

c#

asp.net

iis

I have a text file that contains cached data in JSON format. I'm trying to update the file, but my IIS worker process is locking the file and when I try to write to it, I get the error "The Process Cannot Access The File Because It Is Being Used By Another Process". I've searched for answers on Google and Stack, but I can't seem to find anything related to IIS locking a file. The text file is included in my Visual Studio solution and I am using IIS on my local machine to host my website. For my first question, I'm wondering how I can get IIS to release the file or not lock it at all. For second question, I'm wondering if there's a different approach to prevent IIS from locking my files.

like image 542
Halcyon Avatar asked Dec 26 '22 22:12

Halcyon


1 Answers

IIS is not locking your file. IIS has no idea your file exists. Some application, probably your own, is locking the file.

Try using a program like procmon from SysInternals to find out which process is locking the file.

like image 200
John Saunders Avatar answered Dec 31 '22 01:12

John Saunders