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
Call pop.ShowDialog( )
End Using
4. Browse for the newly created text file
5. Press OK on the OpenFileDialog
6. Now try to delete the folder you created in step 1.
On my system I am being informed that a process is using the folder,
which it is, but why? The OpenFileDialog and SaveFileDialog automatically
instantiate a file handle to the folder when pressing OK? They dont make a
handle to the text file, only the folder...
Any ideas on how I can destroy this handle, I presumed disposing the
OpenFileDialog object would be adequate but obviously not as it should be
disposed by the 4th line.
Nick. 4 4040
BTW, the handle is released once the application is closed, so don't close
it until you have tried step 6.
"NickP" <a@a.com> wrote in message
news:uO******** ******@TK2MSFTN GP03.phx.gbl... 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 Call pop.ShowDialog( ) End Using
4. Browse for the newly created text file 5. Press OK on the OpenFileDialog 6. Now try to delete the folder you created in step 1.
On my system I am being informed that a process is using the folder, which it is, but why? The OpenFileDialog and SaveFileDialog automatically instantiate a file handle to the folder when pressing OK? They dont make a handle to the text file, only the folder...
Any ideas on how I can destroy this handle, I presumed disposing the OpenFileDialog object would be adequate but obviously not as it should be disposed by the 4th line.
Nick.
Hello NickP, BTW, the handle is released once the application is closed, so don't close it until you have tried step 6.
The problem here is the RestoreDirector y property. By default this is set
to false. By default calling ShowDialog() on OpenFileDialog will start in
the current directory for the process. If you change directories in the
dialog it will also change the current working directory of the process.
Unless you set RestoreDirector y process to True the last directory you enter
in the dialog will be the working directory of the process when you finish.
That's why you still have an open handle to the directory.
--
Jared Parsons [MSFT] ja******@online .microsoft.com
All opinions are my own. All content is provided "AS IS" with no warranties,
and confers no rights.
Hi Jared,
Thanks for the info, so presumably I should be able to elliminate this
issue by changing the current working directory before attempting to delete
said folder? I'll have a try of that, many thanks and much appreciation :-)
Nick.
"Jared Parsons [MSFT]" <ja******@onlin e.microsoft.com > wrote in message
news:61******** *************** *@msnews.micros oft.com... Hello NickP,
BTW, the handle is released once the application is closed, so don't close it until you have tried step 6.
The problem here is the RestoreDirector y property. By default this is set to false. By default calling ShowDialog() on OpenFileDialog will start in the current directory for the process. If you change directories in the dialog it will also change the current working directory of the process. Unless you set RestoreDirector y process to True the last directory you enter in the dialog will be the working directory of the process when you finish. That's why you still have an open handle to the directory. -- Jared Parsons [MSFT] ja******@online .microsoft.com All opinions are my own. All content is provided "AS IS" with no warranties, and confers no rights.
Hello NickP, Hi Jared,
Thanks for the info, so presumably I should be able to elliminate this issue by changing the current working directory before attempting to delete said folder? I'll have a try of that, many thanks and much appreciation :-)
Another quick fix is to set RestoreDirector y to true. That will undo the
directory change as soon as the dialog closes
--
Jared Parsons [MSFT] ja******@online .microsoft.com
All opinions are my own. All content is provided "AS IS" with no warranties,
and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kong Li |
last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset
(9.2.0.5) fixed the handle count leak problem. The problem is in
Oracle client component.
Thanks.
Kong
-----
From: Kong Li (likong@email.com)
|
by: Ken Brubaker |
last post by:
I am using DB2 8.5 FP5 on Windows 2000 Server and have noticed what appears
to be a handle leak. When I execute a DB2 connect statement in a command
window, followed by a DB2 connect reset statement, The number of handles
displayed in Windows Task Manager for the db2syscs process does not return
to its original value, but to 1 handle higher.
While this is not a serious issue most of the time, we have applications
connecting every 30...
|
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...
|
by: Sharon |
last post by:
I’m using OpenFileDialog class in a specific InitialDirectory and I want that
files will be selected in the opened dialog when I call ShowDialog().
Actually I wish to select all files in the directory automatically by code.
Is it doable?
How??
--
Regards
Sharon G.
|
by: Chuck Edgeworth |
last post by:
I'm trying to be able to select a combination of files and folders. When I
try to use the OpenFileDialog it will allow me to select them but when I
press the Open button it only informs me of the files I chose not the
folders as well? Am I missing something? I know Microsoft can determine
the folders that are selected because if you do this with the Explorer file
open it will bring up windows with the contents of the folders you selected...
| |
by: barbara_dave |
last post by:
Hi, All,
I want to use the openfiledialog to open different extension files in
different directory( only one type files at one time). I set the
OpenFiledialog InitialDirectory and Filter property for ".dat" files at
first time, it works. When I try to use openfiledialog to set different
InitialDirectory an different Filter property for ".txt" files at
second time, I got frozen window. Even I added code to dispose
openfiledialog after...
|
by: =?Utf-8?B?TW9uaWNh?= |
last post by:
Hi
1- I want to pick a file in my website project using asp.net
2- I added System.Windows.Forms by add references to my project.
3- I attach a button to my project.
4- in side Button1_Click(object sender, EventArgs e) I wrote:
OpenFileDialog filedlg = new OpenFileDialog();
filedlg.Title = "Choose an image to upload";
filedlg.InitialDirectory = @"c:\";
filedlg.Filter = "Image Files (JPG, JPEG, GIF, BMP, TIF,
|
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
I need to use the OpenFileDialog class to get the name of a file, but I don't
want it to check to see if the file is really there since I may just want to
type an arbitrary name in and create it later. I assume the correct way to
do this is to handle the OK button click event. I found the following
example code but the OK button still doesn't seem to go to my event handler.
Any ideas? Thanks, Ray.
OpenFileDialog openLogFileDialog;...
|
by: =?Utf-8?B?QU1lcmNlcg==?= |
last post by:
I have a vb.net program that leaks handles as reported by task manager.
After running for a couple of hours, task manager reports over 1000 handles,
and it continues to grow. I think I am failing to close or dispose
something. I've looked at the code and can't spot the problem. The program
is fairly big (10k lines). I can ask it to do something that always
increases the handle count, so the problem is reproducible.
What I don't know...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |