C# Sucks!
-
[rant]I've only been at it for about an hour and already don't like it! I'm a long c++ programmer, MFC -- MS-Windows. All I want is a form with an edit box where you can type in a filename and a button that will let you browse for the filename. In C++ I would simply use VC++ 6.0 to create an MFC project, create and initialize an object of type OPENFILENAME, then call the win32 api function. Simple. Without knowing better, using Visual Studio .NET 2003 I created a windows C# project, made the form like I wanted (that was pretty intuitive) then clicked the button on the form to get the event handler. There, everything goes to hell in a handbag. The compiler knows nothing about OPENFILENAME structure. So I downloaded the sample C# tutorial project from codeproject. I can't believe the kind of hell C# programmers have to go through just to do one simple call to a Win32 api function.:( Its enough to make me throw in the towel and use C++ instead.[/rant] Isn't there an easier way to accomplish this? -- modified at 17:34 Friday 23rd September, 2005
-
[rant]I've only been at it for about an hour and already don't like it! I'm a long c++ programmer, MFC -- MS-Windows. All I want is a form with an edit box where you can type in a filename and a button that will let you browse for the filename. In C++ I would simply use VC++ 6.0 to create an MFC project, create and initialize an object of type OPENFILENAME, then call the win32 api function. Simple. Without knowing better, using Visual Studio .NET 2003 I created a windows C# project, made the form like I wanted (that was pretty intuitive) then clicked the button on the form to get the event handler. There, everything goes to hell in a handbag. The compiler knows nothing about OPENFILENAME structure. So I downloaded the sample C# tutorial project from codeproject. I can't believe the kind of hell C# programmers have to go through just to do one simple call to a Win32 api function.:( Its enough to make me throw in the towel and use C++ instead.[/rant] Isn't there an easier way to accomplish this? -- modified at 17:34 Friday 23rd September, 2005
-
There most certainly is an easier way to do it and it's approximately 1700 times faster. If you ask nicely, I might even tell you about it
-
[rant]I've only been at it for about an hour and already don't like it! I'm a long c++ programmer, MFC -- MS-Windows. All I want is a form with an edit box where you can type in a filename and a button that will let you browse for the filename. In C++ I would simply use VC++ 6.0 to create an MFC project, create and initialize an object of type OPENFILENAME, then call the win32 api function. Simple. Without knowing better, using Visual Studio .NET 2003 I created a windows C# project, made the form like I wanted (that was pretty intuitive) then clicked the button on the form to get the event handler. There, everything goes to hell in a handbag. The compiler knows nothing about OPENFILENAME structure. So I downloaded the sample C# tutorial project from codeproject. I can't believe the kind of hell C# programmers have to go through just to do one simple call to a Win32 api function.:( Its enough to make me throw in the towel and use C++ instead.[/rant] Isn't there an easier way to accomplish this? -- modified at 17:34 Friday 23rd September, 2005
To Browse for files use
OpenFileDialog
you will find it in the toolbox after that ypu can write some thing likeopenFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "CSharp files (*.cs)|*.cs" ; if (openFileDialog1.ShowDialog() == DialogResult.OK) { // do your work here //OpenFileDialog have properties and method that wil let yo work with file like get file name,opern it..etc } For More info look at OpenFileDialog Class[^]
If you really missed Windows API Function that you did not find counterpart in .Net You can use it By using P/Invoke which let you call function in traditional dll look for Using P/Invoke to Access Win32 APIs[^] MCAD
-
See the other reply. You won't learn about a new language and framework in an hour. Believe me, from experience, C#/.NET is ten times faster/easier to use than the corresponding Win32 API (with or without MFC) in 99% of the cases. You'll just have to search for the appropiate classes to do your job. One thing .NET is a thousand times better is that it has been designed from the ground up, so all the classess are very consistent with each other, whether you are developing a Windows or a web app. Take your time to learn this new technology, and I'll bet anything you won't want to go back! :-> -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005