473,408 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

OpenFileDialog won't release folder?

sam
OpenFileDialog appears to be "holding onto" the parent folder of a
selected file until the application using the dialog quits.

After creating a folder containing a file, I attempted to select that
file with an OpenFileDialog. I used the following code to create the dialog:

Dim a As New OpenFileDialog
a.ShowDialog()
a.Dispose()

When the OpenFileDialog appears, navigate to the file within the folder
and click “Open”.

Leaving the application still running, attempt to delete the Folder
containing this file. On my machine, it fails with “Cannot delete
'myfoldername': It is being used by another person or program"...

Why is this? I haven’t attempted to actually open the file; merely
selected it. It appears as though the OpenFileDialog box is holding onto
the containing folder until the application is closed, afterwhich the
folder can be deleted. Disposing of the OpenFileDialog doesn’t seem to
help either. However, the actual selected file is not being locked--only
the parent folder.

Any ideas what might be causing this?
Jun 25 '07 #1
1 3753
"sam" <sp*******@gtnincs.comschrieb
OpenFileDialog appears to be "holding onto" the parent folder of a
selected file until the application using the dialog quits.

After creating a folder containing a file, I attempted to select
that file with an OpenFileDialog. I used the following code to
create the dialog:

Dim a As New OpenFileDialog
a.ShowDialog()
a.Dispose()

When the OpenFileDialog appears, navigate to the file within the
folder and click “Open”.

Leaving the application still running, attempt to delete the Folder
containing this file. On my machine, it fails with “Cannot delete
'myfoldername': It is being used by another person or program"...

Why is this? I haven’t attempted to actually open the file; merely
selected it. It appears as though the OpenFileDialog box is holding
onto the containing folder until the application is closed,
afterwhich the folder can be deleted. Disposing of the
OpenFileDialog doesn’t seem to help either. However, the actual
selected file is not being locked--only the parent folder.

Any ideas what might be causing this?
What does CurDir return after a.dispose? Have you tried setting
a.RestoreDirectory = True before a.Showdialog? If it is False, the current
directory changes to the directory of the selected file, thus it can not be
deleted. It is not the OpenFileDialog that locks the directory, it's because
the process's current (working) directory has been changed.
Armin

Jun 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mr. B | last post by:
If you can set the 'initial' path of an OpenFileDialog box by something like the following: Dim FilesPath As String ' Files Path FilesPath = "P:\Projects\" FilesPath =...
4
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in...
2
by: Bernie Yaeger | last post by:
I've asked this question before but now I need something different: I need to select files using openfiledialog, which is easy enough. But I want to select a file or files (multiselect) and also...
3
by: juststarter | last post by:
Hello all, I am using an openFileDialog box to select a file (in order to insert it in a database). When the file is selected i am filling a few textboxes with the actual path, filename and...
2
by: Greg | last post by:
I'm a bit confused by this - when I set the InitialDiretory of an OpenFileDialog to be a subfolder within the same folder as the app, the file dialog does not initially display the folder - instead...
9
by: Michael A. Covington | last post by:
Is there any way to hack OpenFileDialog (either in .NET 2.0 or in Win32) that will allow the user to select a folder rather than a file? Better yet, multiselect them. I know about...
0
by: letibal | last post by:
Hello, I have written a windows service that runs under the LocalSystem account (launched when the computer boots up). This service launches a GUI that contains several...
4
by: NickP | last post by:
Hi there, This is really crazy! 1. Make a folder 2. Put a text file in the folder 3. Run the following code... Dim pop As New OpenFileDialog Using pop
3
by: Mike Wesling | last post by:
Hi, does anyone know how to show the OpenFileDialog with "My Computer" as InitialDirectory? I tried it with openFileDialog.InitialDirectory =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.