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