473,412 Members | 2,005 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,412 software developers and data experts.

OpenFileDialog Problem

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 same error.

My code is as follows.

private void diagramButton_Click(object sender, System.EventArgs e)

{

openFileDialog = new OpenFileDialog();

openFileDialog.Filter = "All Files (*.*)|*.*";

openFileDialog.InitialDirectory = "C:\\temp";

openFileDialog.Multiselect = false;

openFileDialog.RestoreDirectory = false;

this.openFileDialog.ShowDialog(this);

if (openFileDialog.FileName.Trim() != string.Empty) {

this.textBox1.Text = openFileDialog.FileName.Trim();

}

openFileDialog.Dispose();

openFileDialog = null;

}
Please tell me the solution for this ASAP.

--
Bye For Now,
Chandu.
Nov 16 '05 #1
4 7955
Hi,

Are you sure that this isn't a problem with explorer?
I often get such error when I have the folder that I want to delete opened
within explorer...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
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 same error.

My code is as follows.

private void diagramButton_Click(object sender, System.EventArgs e)

{

openFileDialog = new OpenFileDialog();

openFileDialog.Filter = "All Files (*.*)|*.*";

openFileDialog.InitialDirectory = "C:\\temp";

openFileDialog.Multiselect = false;

openFileDialog.RestoreDirectory = false;

this.openFileDialog.ShowDialog(this);

if (openFileDialog.FileName.Trim() != string.Empty) {

this.textBox1.Text = openFileDialog.FileName.Trim();

}

openFileDialog.Dispose();

openFileDialog = null;

}
Please tell me the solution for this ASAP.

--
Bye For Now,
Chandu.

Nov 16 '05 #2
Yes..I am sure...The problem is not with the explorer. Because after closing
my application i am able to delete the same folder from the same explorer
window.

-chandu.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Are you sure that this isn't a problem with explorer?
I often get such error when I have the folder that I want to delete opened
within explorer...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
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 same error.

My code is as follows.

private void diagramButton_Click(object sender, System.EventArgs e)

{

openFileDialog = new OpenFileDialog();

openFileDialog.Filter = "All Files (*.*)|*.*";

openFileDialog.InitialDirectory = "C:\\temp";

openFileDialog.Multiselect = false;

openFileDialog.RestoreDirectory = false;

this.openFileDialog.ShowDialog(this);

if (openFileDialog.FileName.Trim() != string.Empty) {

this.textBox1.Text = openFileDialog.FileName.Trim();

}

openFileDialog.Dispose();

openFileDialog = null;

}
Please tell me the solution for this ASAP.

--
Bye For Now,
Chandu.


Nov 16 '05 #3
If you observe my code there is a statement in my code.

openFileDialog.RestoreDirectory = false;

RestoreDirectory property is set to false means the dialog box doesn't
restore the current directory before closing. I made it to true so that it
restores the current directory. Now i can delete the folder from explorer
after closing the openfiledialog. But here i just want to know the current
directory means the directory in which the application is running or the
directory i gave as initial directory.

Please explain this.

Thanks,
Chandu.

"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
Yes..I am sure...The problem is not with the explorer. Because after closing my application i am able to delete the same folder from the same explorer
window.

-chandu.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Are you sure that this isn't a problem with explorer?
I often get such error when I have the folder that I want to delete opened within explorer...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
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 same error.

My code is as follows.

private void diagramButton_Click(object sender, System.EventArgs e)

{

openFileDialog = new OpenFileDialog();

openFileDialog.Filter = "All Files (*.*)|*.*";

openFileDialog.InitialDirectory = "C:\\temp";

openFileDialog.Multiselect = false;

openFileDialog.RestoreDirectory = false;

this.openFileDialog.ShowDialog(this);

if (openFileDialog.FileName.Trim() != string.Empty) {

this.textBox1.Text = openFileDialog.FileName.Trim();

}

openFileDialog.Dispose();

openFileDialog = null;

}
Please tell me the solution for this ASAP.

--
Bye For Now,
Chandu.



Nov 16 '05 #4
Microsoft documents this somewhere. The behavior of open file dialogs
(i.e., the initial directory that they start up in) is not what you would
think, and is not the same in different versions of Windows. Basically,
Windows tries to remember where you most recently opened a file with that
extension, and it goes there. But the scheme for doing this varies among
versions.

As best I can make out, RestoreDirectory has to do with the current
directory in which the program is running; it has little effect on where the
dialogs open up.
"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl...
If you observe my code there is a statement in my code.

openFileDialog.RestoreDirectory = false;

RestoreDirectory property is set to false means the dialog box doesn't
restore the current directory before closing. I made it to true so that it
restores the current directory. Now i can delete the folder from explorer
after closing the openfiledialog. But here i just want to know the current
directory means the directory in which the application is running or the
directory i gave as initial directory.

Please explain this.

Thanks,
Chandu.

"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
Yes..I am sure...The problem is not with the explorer. Because after

closing
my application i am able to delete the same folder from the same explorer
window.

-chandu.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Are you sure that this isn't a problem with explorer?
I often get such error when I have the folder that I want to delete

opened within explorer...

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Nagachandra Sekhar Grandhi" <gn*****@hotmail.com> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl...
> 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 same error.
>
> My code is as follows.
>
> private void diagramButton_Click(object sender, System.EventArgs e)
>
> {
>
> openFileDialog = new OpenFileDialog();
>
> openFileDialog.Filter = "All Files (*.*)|*.*";
>
> openFileDialog.InitialDirectory = "C:\\temp";
>
> openFileDialog.Multiselect = false;
>
> openFileDialog.RestoreDirectory = false;
>
> this.openFileDialog.ShowDialog(this);
>
> if (openFileDialog.FileName.Trim() != string.Empty) {
>
> this.textBox1.Text = openFileDialog.FileName.Trim();
>
> }
>
> openFileDialog.Dispose();
>
> openFileDialog = null;
>
> }
>
>
> Please tell me the solution for this ASAP.
>
> --
> Bye For Now,
> Chandu.
>
>



Nov 16 '05 #5

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

Similar topics

3
by: Jody Gelowitz | last post by:
VS.NET 2002 and 2003 are installed. ..NET Framework 1.0 and 1.1 installed Program running under VisualBasic.NET 2002 with .NET Framwork 1.0 I am experiencing a problem with ADO.NET where the...
3
by: bobrad | last post by:
MAYBE SOMEBODY CAM HELP I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM DIALOG OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = " Access...
8
by: e-mid | last post by:
why does not openFileDialog have closed event? i want to do something; as soon as the dialog closes. is there a way to do this?
1
by: Johann Blake | last post by:
A number of posts have indicated developers having problem getting an OpenFileDialog to startup in a specific directory when the dialog is shown. The first time you show the dialog, the...
6
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...
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...
8
by: marcus.kwok | last post by:
I am having a weird problem and I have can't figure out why it is happening. I create an OpenFileDialog and set a filename filter. When the dialog first opens, the filter works correctly, and...
2
by: MikeY | last post by:
Hi everyone, I"m having a problem with the OpenFileDialog() changing my path to save to my .resources file. I'm a bit baffled why this is happening, even when I set the OpenFileDialog back to...
0
by: mbewers1 | last post by:
Hi I'm having a problem trying to get a customised OpenFileDialog() to fulfil my requirements. The code for this custom-built dialog has been taken from another site...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...

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.