470,586 Members | 1,342 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,586 developers. It's quick & easy.

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 7716
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jody Gelowitz | last post: by
3 posts views Thread by bobrad | last post: by
8 posts views Thread by e-mid | last post: by
6 posts views Thread by barbara_dave | last post: by
3 posts views Thread by juststarter | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.