| | Back to normal this week after last week's Appleish issue. Last week I tried to write a program that accessed a folder in a C# program relative to the folder where the exe was located. It's not easy but I figured it out and have included it as a quick tip complete with source code. If I've missed a totally obvious way, do please write and tell me! Have a great week! | | How to Move Up and Down Folders in C#? It's one of those simple things that you end up doing it the hard way then discovering it's fairly easy with a class to hide the details. The DirectoryInfo class in System.IO Namespace effectively lets you convert from a string to a path and vice versa but does it on one a one to one basis; for each folder you need a DirectoryInfo. You can create an instance from a path or default to where the application is executing. Most importantly it includes parent and SubDirectory access. However I have to use a little trick to make possible Up() and Down( "Matching Folder Name") methods. The Parent member returns another instance of DirectoryInfo and the GetDirectories() method returns an array of DirectoryInfo instances. The trick is that if I'm moving up the current class member instance of DirectoryInfo is replaced with the one for the parent folder and for down, the first matching folder is picked. The class RelativeDirectory also has dir and path members that return the directory name and full path. I've done this as a quick tip. | The Joys of Integration Testing At British Aerospace and my last two jobs, I've worked as part of a team so the code that gets released is not just my own but also has to work with other's code. We don't use a continuous build/automatic regression testing system here so while working on a particular release, I refresh my entire code base from the vcs repository once a week, build it all and work against that. It's not perfect but generally most developers are smart enough to check in code that compiles. People who don't manage that get found out very quickly. It's far worse than creating code that doesn't work as it's guaranteed to annoy fellow team members. As happened to me today though, a fellow team member added a new feature that broke my code! It compiled but had been checked in early, before a database change that it needed had been done so when I ran it, a table column was missing and bang. Unfortunately that developer was located in a different time zone several hours west of me! It got sorted eventually! The moral is keep integrating often and test it, and on occasions be very patient and work on something else! | The most frequent question I get emailed "Sir, please tell me which programming language I should learn first?". Of course without context, it's a tough one to answer. Of the three I cover here, my preferences are C and C#. C because it covers most of the fundamentals and C# because it lets you do easy GUI development and is pretty forgiving. My first programming language was BASIC and for learning it was OK. Through the 80s, I bet there was an enormous amount of business.software written in Basic, particularly Microsoft 8K basic. Why did I exclude C++? It's quite hard to explain the subtleties of C++ to a beginner without them knowing a bit about programming already or having someone handy to explain the many interesting error messages that C++ compilers will spout. I think I once got several hundred error messages because of a misplaced semi-colon with an early version of Microsoft's C++ compiler. But that's my opinion. What's yours? | Never Programmed Before? Start Here Learn how to program computers as a living or just for recreational fun. Find out how to make a computer do what you want. | | | | C / C++ / C# Ads | | | | Featured Articles | | | | | More from About.com | | | | | | Plan a Unique Vegas Wedding The minister, music and champagne are just the beginning -- why not get married aboard a helicopter or have a pirate swing in to deliver your rings? Arrrr! More>
| | | | Join About.com's User Panel! Share your opinions and help us make About.com more relevant, informative and enjoyable to use. More>
| | | | | Sign up for more free newsletters on your favorite topics | | | | You are receiving this newsletter because you subscribed to the About C / C++ / C# newsletter. If you wish to change your email address or unsubscribe, please click here. About respects your privacy: Our Privacy Policy Contact Information: 249 West 17th Street New York, NY, 10011 © 2010 About.com | | | | | Must Reads | | Advertisement | |
No comments:
Post a Comment