473,722 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_C lick(object sender, System.EventArg s e)

{

openFileDialog = new OpenFileDialog( );

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

openFileDialog. InitialDirector y = "C:\\temp";

openFileDialog. Multiselect = false;

openFileDialog. RestoreDirector y = false;

this.openFileDi alog.ShowDialog (this);

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

this.textBox1.T ext = openFileDialog. FileName.Trim() ;

}

openFileDialog. Dispose();

openFileDialog = null;

}
Please tell me the solution for this ASAP.

--
Bye For Now,
Chandu.
Nov 16 '05 #1
4 8007
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

"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:uo******** ******@TK2MSFTN GP09.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_C lick(object sender, System.EventArg s e)

{

openFileDialog = new OpenFileDialog( );

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

openFileDialog. InitialDirector y = "C:\\temp";

openFileDialog. Multiselect = false;

openFileDialog. RestoreDirector y = false;

this.openFileDi alog.ShowDialog (this);

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

this.textBox1.T ext = 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******** ********@TK2MSF TNGP09.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

"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:uo******** ******@TK2MSFTN GP09.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_C lick(object sender, System.EventArg s e)

{

openFileDialog = new OpenFileDialog( );

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

openFileDialog. InitialDirector y = "C:\\temp";

openFileDialog. Multiselect = false;

openFileDialog. RestoreDirector y = false;

this.openFileDi alog.ShowDialog (this);

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

this.textBox1.T ext = 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. RestoreDirector y = false;

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

"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:OF******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP09.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

"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:uo******** ******@TK2MSFTN GP09.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_C lick(object sender, System.EventArg s e)

{

openFileDialog = new OpenFileDialog( );

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

openFileDialog. InitialDirector y = "C:\\temp";

openFileDialog. Multiselect = false;

openFileDialog. RestoreDirector y = false;

this.openFileDi alog.ShowDialog (this);

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

this.textBox1.T ext = 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, RestoreDirector y has to do with the current
directory in which the program is running; it has little effect on where the
dialogs open up.
"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:eY******** ******@tk2msftn gp13.phx.gbl...
If you observe my code there is a statement in my code.

openFileDialog. RestoreDirector y = false;

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

"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:OF******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP09.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

"Nagachandr a Sekhar Grandhi" <gn*****@hotmai l.com> wrote in message
news:uo******** ******@TK2MSFTN GP09.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_C lick(object sender, System.EventArg s e)
>
> {
>
> openFileDialog = new OpenFileDialog( );
>
> openFileDialog. Filter = "All Files (*.*)|*.*";
>
> openFileDialog. InitialDirector y = "C:\\temp";
>
> openFileDialog. Multiselect = false;
>
> openFileDialog. RestoreDirector y = false;
>
> this.openFileDi alog.ShowDialog (this);
>
> if (openFileDialog .FileName.Trim( ) != string.Empty) {
>
> this.textBox1.T ext = 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
2998
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 Connection object (OleDBConnection) will not Open (conIncident.Open) given the following situation: 1. Program is loaded and connection is established to Access database on C:
3
360
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 (*.mdb)|*.mdb|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) DataBaseLocation.Text = openFileDialog.FileName;
8
6040
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
2338
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 InitialDirectory will cause the dialog to show files in that directory. However, any further times that the dialog is displayed, the directory that is shown will always be the one initially used regardless of the RestoreDirectory setting. This appears to be...
6
3007
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 ".txt" files at second time, I got frozen window. Even I added code to dispose openfiledialog after...
3
3468
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 extension of the file, so i no longer need the openfiledialog, thus i am using openfiledialog1.reset() method to reset it. (i have also tried openfiledialog.dispose() with no results) The problem i am encountering is that the folder in which the...
8
6093
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 only the files I want to see appear in the file list box. When I change the filter to one of the other filters, all the files in the list disappear. If I then manually type a filter into the "Filename" textbox, then the files appear and the filter...
2
4717
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 the inital directory where the .resource file resides. What I am trying to do is get the location of my database and save it to string format in my resource file (un-embedded). When I go to save this information to my .resouce file it creates...
0
2175
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 (http://www.codeproject.com/KB/dialog/FileDialogExtender.aspx) ) and allows the user to select the viewing method before opening the dialog to show a file directory. The following event is assigned to a button on my form which, when prompted, displays the dialog. public...
0
8738
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9381
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5994
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4501
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
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
3
2146
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.