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 4024
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....
|
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...
|
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...
| |
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...
|
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";...
|
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...
|
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...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |