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 / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

an OpenFileDialog problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tlemcenvisit - 26 May 2005 20:17 GMT
Hello
I am trying to open a text file, I use this code :

private: void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() == ::DialogResult::OK )
     {
        if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
        {
           myStream->Close();
        }
     }
}

The problem is that I obtain this error messages :

error C3083: 'DialogResult': the symbol to the left of a '::' must be a type
error C2039: 'OK' : is not a member of '`global namespace''
error C2065: 'OK' : undeclared identifier

All the errors are in this line :

if ( openFileDialog1->ShowDialog() == ::DialogResult::OK )

Please help me
Thanks
Jochen Kalmbach [MVP] - 26 May 2005 20:28 GMT
Hi tlemcenvisit!

> All the errors are in this line :
>
> if ( openFileDialog1->ShowDialog() == ::DialogResult::OK )

If a symbols starts with "::" it is assumed that it is in the
global-namespace!
So please remove the "::" at the beginning of the "DialogResult::OK"!

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/

tlemcenvisit - 26 May 2005 21:05 GMT
I have doing it
Now I have two error messages:
e:\projets visual studio\rien\rien\Form1.h(121) : error C2039: 'OK' : is not
a member of 'System::Windows::Forms::Form::DialogResult'
       e:\projets visual studio\rien\rien\Form1.h(24) : see declaration of
'System::Windows::Forms::Form::DialogResult'
e:\projets visual studio\rien\rien\Form1.h(121) : error C2065: 'OK' :
undeclared identifier

Please help me

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.