473,224 Members | 1,410 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,224 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 7939
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.