Shell32 FileOperation and Open Resources

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use Shell32 objects to move files to the recycling bin upon user command. The problem is that I have the resource open prior to the user making the decision to delete the resource (image files). I close them and call Dispose on them, but I get an 0x402 response and the image is not recycled. I know it has something to do with using the resource because I can delete other resources that aren't in use.

I have also tried invoking garbage collection prior to executing the Shell32 command and I still get the same response.

Any ideas on how to detach from the resource? Also, what does 0x402 mean exactly?

Thanks,
 
Brain,

Can you paste the code of opening the image? There is a chance that you are
not using proper methods to close the image file. Your code will help me to
investigate the problem.

--
Shak
(Houston)


Brian Reed said:
I am trying to use Shell32 objects to move files to the recycling bin upon
user command. The problem is that I have the resource open prior to the
user making the decision to delete the resource (image files). I close them
and call Dispose on them, but I get an 0x402 response and the image is not
recycled. I know it has something to do with using the resource because I
can delete other resources that aren't in use.
I have also tried invoking garbage collection prior to executing the
Shell32 command and I still get the same response.
 
Here is the way I load the image:

m_imgCurImage = DRW.Image.FromFile(m_strFilePath, true);
m_bImageLoaded = true;


The m_imgCurImage is a member variable and is held onto until I close it or move on to the next one.

Here is the way I close the image:

private void UnloadImage()
{
if(m_bImageLoaded)
{
m_imgCurImage.Dispose();
m_imgCurImage = null;
}

m_bImageLoaded = false;
}


Any help would be great.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top