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# / May 2007

Tip: Looking for answers? Try searching our database.

OpenFileDialog Event Handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ray Mitchell - 30 May 2007 21:19 GMT
I need to use the OpenFileDialog class to get the name of a file, but I don't
want it to check to see if the file is really there since I may just want to
type an arbitrary name in and create it later.  I assume the correct way to
do this is to handle the OK button click event.  I found the following
example code but the OK button still doesn't seem to go to my event handler.  
Any ideas?  Thanks, Ray.

OpenFileDialog openLogFileDialog;
private void GetLogFileName()
{
  openLogFileDialog = new OpenFileDialog();
  openLogFileDialog.ShowDialog();
}

private void openLogFileDialog_FileOk(object sender,
System.ComponentModel.CancelEventArgs e)
{
   // handle the file name in openLogFileDialog.FileName
}
Peter Duniho - 30 May 2007 21:27 GMT
> I need to use the OpenFileDialog class to get the name of a file, but I  
> don't
> want it to check to see if the file is really there since I may just  
> want to
> type an arbitrary name in and create it later.

I don't know why your FileOk handler isn't executing when the user clicks  
the Ok button.  However, it seems to me that you would be better off just  
setting the CheckFileExists property of the dialog to "false".

Pete
Ray Mitchell - 30 May 2007 21:39 GMT
> > I need to use the OpenFileDialog class to get the name of a file, but I  
> > don't
[quoted text clipped - 7 lines]
>
> Pete

I didn't realize this property existed.  It's just what I need.  Thanks!

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.