Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: Kaz Kylheku Newsgroups: comp.programming Subject: Re: c# .net 4 unable to move file - file in use by another process (by itself) Date: Thu, 16 Oct 2014 15:41:48 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 16 Message-ID: <20141016083723.39@kylheku.com> References: <4c284fb9-3878-43e0-9d11-85b7c33ce269@googlegroups.com> NNTP-Posting-Host: X+c6YNb3AaWMPA3YfA4opg.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: slrn/pre1.0.0-18 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.programming:4829 On 2014-10-16, lachlann@gmail.com wrote: > When i attempt to rename the file from .pending -> .failed i get an error > "file is in use by another process". originally this service was > multi-threaded so i assumed it was a collision with other threads however > upon further investigation i've made it single-threaded and it is still > failing. it even happens when stepping through the code using the debugger > (VS2010). > > I've moved all "file" logic into 3 methods: > readfromfile > writetofile > movefile Who closes the handle to release the file? Is it possible that you might be leaving that responsibility to a finalization performed by the garbage collector?