When I execute the following code to delete and move a file my worker process hangs:
File.Delete(FullSourceFilePath);
File.Move(FullTempFilePath, FullSourceFilePath);
// update db
Data.AdminUpdateFileSizeandBitrate(FileId, SizeInbytes, Bitrate);
Response.Redirect("?m=File replaced!");
The folder FullSourceFilePath
has more than 15000 files in it.
Above code causes site to hang (only this site) if the file that needs to be moved is larger than around 5 MB. When this problem arises my worker process starts consuming memory and gradually my server is brought to its knees.
The only recovery solution is then to issue the IISRESET /RESTART
command.
My environment is:
IIS6 running on Windows 2003 x86 SP2
Web site written using ASP.NET 4.0 and C#