Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Select file from dialog box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RP - 11 Oct 2007 11:33 GMT
I have a text box in which I need the path of the file a user selects
from the dialog box. I also want that the dialog box is filtered to
show only image files, and when the user selects this file, the path
of the file is shown on the text box.
Jon Skeet [C# MVP] - 11 Oct 2007 11:38 GMT
> I have a text box in which I need the path of the file a user selects
> from the dialog box. I also want that the dialog box is filtered to
> show only image files, and when the user selects this file, the path
> of the file is shown on the text box.

It's not clear whether you're talking about a web application or a
WinForms application, but have you looked at the OpenFileDialog class?

Jon
RP - 11 Oct 2007 11:40 GMT
Windows Forms application.
Jon Skeet [C# MVP] - 11 Oct 2007 13:02 GMT
> Windows Forms application.

And have you looked at OpenFileDialog?

Jon
harborsparrow - 12 Oct 2007 03:49 GMT
Try something like this:

           OpenFileDialog openFileDialog1 = null;
           string newfilespec;
           try
           {

               openFileDialog1 = new OpenFileDialog();

               openFileDialog1.Title = "Select a text file to add to
the search list";
               openFileDialog1.InitialDirectory = "C:\\";
               openFileDialog1.Filter = "txt files (*.txt)|*.txt|All
files (*.*)|*.*";
               openFileDialog1.FilterIndex = 2;

               if (openFileDialog1.ShowDialog() == DialogResult.OK)
               {

               }

> > Windows Forms application.
>
> And have you looked at OpenFileDialog?
>
> Jon

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.