Working out is indeed extremely important, but what a lot of people don't realize is that your weight is determined by 75% diet and 25% exercise. 8 years ago i was 5'9" and was extremely skinny at 125lbs. I've maintained a weight at around 170-175 for the last several years mostly due to changes in my eating habits. As a fulltime software engineer who only works out 2x a week now, I maintain my weight mostly through several key points that other people may have already mentioned:
1. Cut out all refined carbs/sugars. Stick to whole wheat grains and brown rice.
2. Minimize, but don't eliminate, fat intake. Obviously this means staying away from fried foods, but you can get healthy fats from sources like fish, nuts, olive oil, and vinaigrette salad dressing.
3. Make sure you eat a good amount of protein (the exact amount will differ according to how much activity you can actually do), but protein builds muscle and will help you to feel full longer.
4. Don't let more than 3 hours pass without eating something. This usually means you'll eat 5-6 meals in a day.
5. ALWAYS have a substantial breakfast. This will jump start your metabolism for the day and actually reduce the likelihood you'll overeat later in the day.
Of course, if you can find time to exercise when you can, you'll have the best results. Otherwise, following these guidelines should make a pretty big impact by itself.