473,804 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3786
"sam" <sp*******@gtni ncs.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.RestoreDirect ory = 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
2316
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 = OpenFileDialog1.InitialDirectory HOW can you set a 'current' path? For example:
4
8009
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 Explorer i am getting error saying that cannot delete that folder as some process is using it. After that i selected a file from the same folder in OpenFileDialog. When i tried to delete the folder after selecting the file also it is giving the...
2
1395
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 single click select a folder or folders (double click would open the folder, as the openfiledialog now does). I don't want to just browse the folder. For example, when I cut a cd using Record Now, it can select both files and entire folders and...
3
3471
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 extension of the file, so i no longer need the openfiledialog, thus i am using openfiledialog1.reset() method to reset it. (i have also tried openfiledialog.dispose() with no results) The problem i am encountering is that the folder in which the...
2
7991
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 it shows the last used folder (this persists after closing the app). However, if I use a different path (e.g. "C:\\") then every time the dialog is shown, it starts at the correct directory every time. Is there something special about an...
9
41561
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 FolderBrowserDialog, but it's not satisfactory because it doesn't show or follow shortcuts, and also because users are not as familiar with it.
0
2419
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 OpenFileDialog/FolderBrowser components for which the initial directory/folder root is set to Desktop. When I log on as a user, interacts with the GUI and open a filedialog, the Desktop folder from the localservice account shows up (at least its
4
4041
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
9886
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 = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7638
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.