OpenFileDialog creates handle to a folder

H

Hayato Iriumi

Hello, folks.
I have an issue with OpenFileDialog. Let's say I chose a file at C:
\TestFolder\TestFile.txt using OpenFileDialog. After I choose the
file, I tried to delete the folder from Windows Explorer, but it says
that another process is being used by another person or program.

So I opened up Process Explorer and checked my Windows application. I
found out that it was holding a handle to the folder that contains the
file I just chose. Whenever I use OpenFileDialog to choose a file, it
seems to create a handle to the folder. I can delete the folder when I
close the application or just close the handle from Process Explorer,
but I need to get around this issue programmatically.

So my question is how do I avoid creating a handle to the folder that
contains the file I chose from OpenFileDialog?
 
H

Hayato Iriumi

After a few hours of poking around, found that RestoreDirectory should
be set to True.
I hope this helps people who are having the same issue.
 

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

Top