Access denied from another thread

Posted by Lobuno on Stack Overflow See other posts from Stack Overflow or by Lobuno
Published on 2010-05-24T08:08:02Z Indexed on 2010/05/24 8:11 UTC
Read the original article Hit count: 251

Filed under:
|
|

Hello!

In a program I span a thread ("the working thread"). Hera I copy some files write some data to a database and eventually, delete some other files or directories. Everything works fine. The problem is now, that I decided to move the deleting operation to some other thread. So the working thread now copies the files or directories, writes to the database, and , if there is a need to delete some other files this thread spans another thread and that second thread deleted the needed files or directories.

The problem is that,the deletion used to work 100% when done in the working thread, now when the same is done in the secondary thread, I sometimes get an "Access denied" error and the files cannot be deleted. And no, the working thread is definitely NOT acceding the files and directories to delete at this moment.

Sometimes (but not always) the main thread is impersonating some user, so if needed , the deleting thread is also running under impersonation just to grant the needed permissions to delete the files, so that should not be the problem.

Anybody has a clue why this could be happening?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about winapi