Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a file open dialog box which allows the user to select a file from the drive. I need to display the path and file name of the selected file dynamically as and when the user selects in the title bar of the form.

For ex:

C:\Documents and Settings\My Documents\My Pictures

In the above example I need to dynamically display each of these when user selects.

c:\Documents and Settings
c:\Documents and Settings\My Documents
c:\Documents and Settings\My Documents\My Pictures etc..

Can you help me?

Thanks in advance.
Posted
Updated 9-Oct-11 22:46pm
v2

You change the form title text with the code below:
C#
// in your file select handler
this.Text = selectedfilename;
 
Share this answer
 
You can't do that dynamically for each subfolder, only for the fileOk event

There is no event for the selection of folders...
The OpenFileDialogClass is sealed, so you can't make a custom Dialog easily...
 
Share this answer
 
Comments
Member 7979279 10-Oct-11 5:10am    
Ok then how do I do it for a selected file path as a whole if not for sub folder paths.. Is that possible???
MZwahlen 10-Oct-11 5:22am    
try this:
var diag = new OpenFileDialog();
var diagResult = diag.ShowDialog();

if(diagResult == System.Windows.Forms.DialogResult.OK) {
this.Text = diag.FileName;
}
Member 7979279 10-Oct-11 5:31am    
Thanks loads....Its working Fine :) :) :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900