?
Solved

Code Snip C#

Posted on 2006-05-21
8
Medium Priority
?
273 Views
Last Modified: 2012-06-21
I am sure somewhere there is the following code I would like to get:

File Path Box with Browse Button that opens the Windows file browser and when the file is selected
it puts it in the Path Field..  
0
Comment
Question by:AEII
  • 5
  • 2
8 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 16731615
Hi AEII,

1. placed a folderbrowsedialog, a button and a textbox on a form
2. and used this code in the button click eventhandler

--------
            folderBrowserDialog1.ShowDialog();
            if(folderBrowserDialog1.SelectedPath!="")
            textBox1.Text  =  folderBrowserDialog1.SelectedPath;
--------

3. it will show the selected path in the textbox1 if one is selected

hope this helps a bit
bruintje
0
 
LVL 19

Assisted Solution

by:Fahad Mukhtar
Fahad Mukhtar earned 800 total points
ID: 16731830
a correction:
its FolderBrowserDialog class actually

FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog ();
// Show the FolderBrowserDialog.
DialogResult result = folderBrowserDialog1.ShowDialog();
if( result == DialogResult.OK )
        {
            MessageBox.Show(folderBrowserDialog1.SelectedPath);
        }
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16731835
you can place the dialog on your form too, in 2005 at least
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 44

Expert Comment

by:bruintje
ID: 16731842
its a choice depending on your application, so no correction but an addition i tested before posting :)
0
 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 16731855
yes...
FolderBrowserDialog wasnt included in VS.Net 2002 (.net 1.0 FCL) (the code wont work for .net 1.0)
FolderBrowserDialog was included in VS.Net 2003 (.net 1.1 FCL) but wasnt included in the toolbox..(the code will work for .net 1.1)
 Finally in vs 2005 (.net 2.0) the control included in the toolbox (the code will work for .net 2.0)
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16731859
:) you are correct i should've mentioned that in the comment
0
 

Author Comment

by:AEII
ID: 16734229
Well we are getting close, but one more thing ...

The FolderBrowser only get to Folder Level ... I need to select
a specific .exe (file level)
0
 
LVL 44

Accepted Solution

by:
bruintje earned 1200 total points
ID: 16734293
that would be pretty much the same with another dialog

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            // Show the openFileDialog.
            DialogResult result = openFileDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                if(openFileDialog1.FileName !="")
                textBox1.Text  =  openFileDialog1.FileName ;
            }
       
        }
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Six Sigma Control Plans
Progress

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question