Monday, December 29, 2008

SharePoint Tutorial: Connecting SQL Reporting Services to a SharePoint List

Sometimes you may need to create reports on the SharePoint list data. For example, you may need to create a report for your manager on surveys entered by your users. You can use SQL Reporting Services to connect to a SharePoint list and develop a report from that data.

I've created a tutorial and a video on how to do this.

If you have any questions, please post a comment and I will try to answer to the best of my ability.



Wednesday, December 24, 2008

Feliz navidad, amigos!

I want to wish all of you a joyous holiday!

Here are a few treats for you. I hope you like them.

The first show is Bolek and Lolek having a little winter fun. For those of you who aren't familiar, Bolek and Lolek is an adorable cartoon from Poland.


The second show is one of my favorite Christmas songs. It's special to me because I lived in Puerto Rico for a few years, and I've spent a few fun Christmases in the land of Los Boriquas. It brings back a lot of happy memories. This is a live performance of Feliz Navidad, from Jose Feliciano.


The third show is another of my favorite Christmas song arrangements. This duet from David Bowie and Bing Crosby, in my opinion, rocks the house! It's a great mix of the classic and the contemporary. This is one of Bing Crosby's final appearances.


Finally, this is for my mother. Her favorite Christmas song is Happy Christmas (War is Over), by John Lennon. Others have covered this song, but she only likes the version from John Lennon.

Tuesday, December 23, 2008

C# Tutorial: Using FtpWebRequest to Perform FTP Actions


Click the link to download the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.




Introduction


Before .NET 2.0, coding FTP functionality was somewhat cumbersome. You either had to purchase third-party classes and libraries or you had to spend hours coding in order for the functionality to work.

.NET 2.0 launched a number of tools to make development easier. A class called FtpWebRequest in the System.Net library makes coding FTP functionality much easier.

I have created a demonstration on how to use this class. In this demonstration, I will be creating a GUI application that will upload a file to an FTP server.

If you have any questions, please leave a comment and I will answer your question to the best of my ability. :)

The Tutorial


You can download the source code for this tutorial from the link that appears at the top of this post.

Part 1:

Part 2:

Part 3:


Additional Reading


OpenFileDialog (MSDN)
FtpWebRequest (MSDN)
Simple FTP Demo Application Using C# .NET 2.0 by Mohammed Habeeb
Uploading File using FtpWebRequest by Faraz Shah Khan

Thursday, December 18, 2008

C# and SharePoint 2007 Tutorial - Accessing the SharePoint Data Using Web Services (Part 3)

This is part 3 of the series. If you haven't read parts 1 and 2, please click on the following links to read:


I have published part 3 of the series. The tutorial can be accessed from the link at the end of this post.

If you have any questions, please post a comment and I will answer to the best of my ability. :)



Enjoy!

Tuesday, December 9, 2008

C# and SharePoint 2007 Tutorial - Accessing the SharePoint Data Using Web Services (Part 2)

This is part 2 of the series. If you haven't read part 1, please read it here.

I have published part 2 of the series. The tutorial can be accessed from the link at the end of this post.

If you have any questions, please post a comment and I will answer to the best of my ability. :)



Click to read Part 3 of the tutorial
Enjoy!

Monday, December 8, 2008

Workaround for Installing SharePoint Extensions for Visual Studio on Windows XP


Note: Part II of the SharePoint "Behind the Scenes" Tutorial will be posted tomorrow.


The SharePoint Extensions for Visual Studio (versions 2005 and 2008) make SharePoint development so much easier. However, it assumes that you are developing on a machine with Windows Server 2003, which has the SharePoint Server components already installed.

What if you develop on a Windows XP or Windows Vista machine, and you port the code to a SharePoint server? Unfortunately, you cannot install the SharePoint Extensions on a Windows XP or Windows Vista machine out of the box.

However, with a small registry hack, you will be able to install SharePoint Extensions for Visual Studio on a Windows XP or Windows Vista machine. I did the registry hack on my XP machine, and I was able to install the extensions.

Warning: Approach registry hacks with caution. Make sure you make an image of your machine or a backup of your registry before doing the hack in case something goes wrong.

If you would like to see how it's done, click here to see the video demonstration (WMV file)



Source: Janne Matilla's Blog

Wednesday, December 3, 2008

C# and SharePoint 2007 Tutorial - Accessing the SharePoint Data Using Web Services (Part 1)

As I promised, SharePoint developers, I wrote a tutorial on using a web reference to access SharePoint data using a C# program. This is very useful if you don't want to run your program on the same server where SharePoint 2007 is installed. The tutorial can be accessed from the link at the bottom of this post.

If you have any questions, please post a comment and I will answer to the best of my ability. :)



Click to read Part 2 of the tutorial
Click to read Part 3 of the tutorial

Enjoy!

Monday, December 1, 2008

So how bad is Wikipedia really?



I was listening to the radio the other morning while I was getting ready for work, and the radio host had a professor from one of the local universities as his guest. I wasn't really paying attention to the interview until the professor haughtily stated that he "automatically fails papers that cite Wikipedia as a source." My first thought was, "Hmm - pretty draconian, don't you think?" However, it made me think - is Wikipedia really that bad?

Since 2001, Wikipedia's purpose was to become an encyclopedia that can be read and edited by anyone. Although it was intended to be a supplement to Nupedia (the on-line encyclopedia written by experts), it eventually replaced Nupedia, and it has become a phenomenon.

The openness of Wikipedia is a blessing and a curse.

The blessing is information can easily change virtually in real time, whereas with printed media, it would take time to rewrite or add an entry and republish the media. For example, if a major political figure passes away or if someone recently gets elected to office, the information is readily available on Wikipedia within seconds of the announcement, while one would have to wait for a new edition of the printed media. I also think the ability to openly share ideas and thoughts is a blessing as well. Sometimes the academic press overlook people who are extremely knowledgeable in a subject because they don't have an advanced degree.

The curse is any yahoo with a computer can write anything he or she pleases in the article. There are numerous incidents of pranksters gone wild on Wikipedia, including:

  • In 2005, Brian Chase anonymously posted that John Seigenthaler, a well-known writer and journalist, had a hand in the assassinations of Robert Kennedy and John Kennedy. This article remained on the site for four months.

  • In 2007, Turkish historian Taner Akcam was briefly detained in Montreal because of false information on his Wikipedia page about being a terrorist.

  • Numerous reports on false information being added to celebrities' or well-known figures' Wikipedia pages, including most recently reports on false information on former Vice Presidential candidate Sarah Palin's and golfer Fuzzy Zoeller's Wikipedia pages.



Another problem that I see with Wikipedia is they are slow to monitor information posted on a page. To prove this, I did an experiment with Wikipedia. I anonymously posted false (but not libelous) information about a well-known figure on the Wikipedia page - I won't say which figure ;). It took them about 4 weeks to remove the false information on the page.

So, is Wikipedia really as bad as they say? Depends on what you are researching. Based on my experience, I found that the majority of the technology articles were accurate and I could safely cite a number of them as sources. I also found that a number of pages on tangible objects (like cats and chicken soup) were also accurate. However, I have found that posts on controversial figures or events were not always accurate and were frequently "victims" of Wikipedia vandals.

I also think that despite some of its problems, Wikipedia gets too much of a "bad rap" from academia. For example, in this story in the New York Times, a history department at Middlebury College banned citing Wikipedia as a source because there was an obscure error in a post on the Shimabara Rebellion. If this obscure error was printed in an academic history book, I don't think that it would have caused as much of a kerfuffle.

P.S. On a lighter note, here's some humor about Wikipedia (and the Terms and Conditions) from one of the funniest stand-up comedians ever - Eddie Izzard (WARNING: STRONG LANGUAGE):

Friday, November 28, 2008

New Blog - Linux Training

I've just launched a new blog which will contain lessons in Linux. If you are interested in taking a peek at it, here is the site:

http://mwalinu-linuxtraining.blogspot.com

Thursday, November 27, 2008

Adding a DSN to a Machine using Visual Basic .NET Code




Click the link to download the GUI version of the source code for this post

Click the link to download the Console version of the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.




While it is relatively simple to manually add a DSN to a machine, you may have a project where you have to automatically add a DSN to a machine. For example, I was working on a PC-based application project (including the setup and deployment package) that used a DSN on the user's PC to connect to the data source. My user base wasn't the most technically savvy bunch, so I wanted to make their user experience easier by automatically creating the DSN for them. Using .NET, you can create a program that will automatically create a DSN on a machine.

I have two sample versions of this application. The first sample is using a GUI application to perform the process. The second sample is using a console application to perform the process. You can download one or both of these samples by clicking on the links at the top of the post. I also published an instructional document on Scribd that you may also use for your reference.

Enjoy!

Wednesday, November 26, 2008

Happy Thanksgiving!

I want to wish all of the readers in the States a Happy Thanksgiving!

In the spirit of Thanksgiving, here is a hilarious clip (posted by crystalcheats) from the Thanksgiving episode of WKRP in Cincinnati:

How To Add Third-Party Widgets to Your SharePoint Site



Digg!


Here is an example of a SharePoint site using third-party widgets. The widgets on the right are the Google Map and the Yahoo! Map widgets. The one in the center (left) is one that plays the Peanut Butter Jelly Time video.


Web widgets are useful pieces of code that will allow you to "jazz up" your site without having to compile or use your own code. For example, on one of the sites at work that I had to develop, I'm using the Mapquest widget to allow the users to easily get driving directions. Yahoo! and Google also have some useful widgets that you can use as well.

You can easily embed the widgets on your web page, social networking page, or blog, and by using the Content Editor Web Part, you can use these widgets on your SharePoint 2007 site as well.

I've recently published (on Scribd) step-by-step instructions on how to add third-party widgets to your SharePoint site. You can click on the link below for the directions.



Enjoy!

P.S. to the developers who are reading this: You're probably champing at the bit to write some code to interact with SharePoint. I haven't forgotten about you! I will be featuring more examples of interacting with SharePoint using code over the next few weeks.

Tuesday, November 25, 2008

How to Copy a List on SharePoint 2007 From One Site to Another Site Using Existing SharePoint Functionality


Digg!


If you work in SharePoint 2007, you may have to copy or move a list from one site to another site for one reason or another. For example, you may have to move a list from one site to another, or a site administrator likes the looks of how a list was created on another site and s/he would like to have that list for his or her own data without having to recreate the list manually.

While you can copy or move the lists programmatically, it may take some time to do. Using SharePoint's existing functionality, you can copy or move a list from one site to another site without having to write a line of code.

I've recently published (on Scribd) step-by-step instructions on how to copy a list using SharePoint's existing functionality. You can click on the link below for the directions.



Enjoy!

Sunday, November 23, 2008

My Whitepaper "Number Systems in Computers" Makes the Scribd Hot List

Yesterday, my whitepaper Number Systems in Computers made the Scribd hotlist! The whitepaper is a tutorial on interpreting the number systems used in computers (decimal, hexadecimal and binary).

If you're interested in reading the document, here it is:
Number Systems in Computers

Wednesday, November 19, 2008

SharePoint Development - The Essential Tool Set


Digg!



Please make sure that you install the SharePoint Extensions for your Visual Studio environment.
Extensions for Visual Studio 2005
Extensions for Visual Studio 2008

For a reference to the SharePoint Class Library: MSDN on Microsoft.SharePoint


People who know how to develop in .NET (particularly C# and ASP.NET) already know the foundations for developing for SharePoint 2007. All you need to know is the classes that SharePoint uses, how to access data on SharePoint through your code using GUIDs, and if you are also the SharePoint administrator, how to configure SharePoint to use the custom code by referencing the assembly information.

So how the @#&$% does the developer get the GUIDs and the assembly information?


Note
Before beginning your development project, check out the CodePlex site. CodePlex is Microsoft's open source community. There are numerous tools on this site available for your use, and someone may have already written a tool or web part that you may have to develop.


There are a number of tools that I use to assist me with my SharePoint development. All of these tools that I use are not only free to use, but the majority of the tools are endorsed by Microsoft (the manufacturers of SharePoint and .NET).


  • Stramit Caml Viewer
    Site for Caml Viewer
    Written by Renauld Comte, this robust tool not only gives you information about list and view GUIDs, but it also generates CAML queries for you. So if your application is using CAML queries to get the information, this tool saves you a boatload of time because it not only generates the XML for the CAML query, it also generates the StringBuilder logic for creating the XML for the CAML query!

  • A Simple GUID Picker
    Site for the GUI Picker
    Written by Ronalus, this tool allows you to get the GUIDs for the lists and views on a SharePoint site. This tool is simple yet useful. I use this tool when I'm doing reporting using SharePoint data and SQL Reporting Services since you need to know the list and view GUIDs to connect to the SharePoint "data source".

  • Reflector
    Site for Reflector tool
    Originally written by Lutz Roeder and maintained by Red Gate, this tool is essential for development. This tool returns the assembly information for a class library (dll). All you have to do is drag and drop the dll into the tool, and it will return the information for you, including the assembly information (which is needed for configuring the SharePoint server to use your custom web part or program) and the classes that are part of the library.

    If you have Windows Media player, you can see it in action in this video.

  • Warmup Server
    Download Warmup Server
    Ideally, you want to create a virtual environment in order to do your SharePoint development. If you develop in a virtual environment, then this is the tool for you. This tool allows you to create a MOSS 2007 VPC (Virtual PC) image that you can use. Here is the tutorial on using this tool. I haven't tried it since in my environment, we actually have physical machines that we work from, although I am leaning toward setting up virtual environments for my development.

  • SharePoint Spy
    Site for SharePoint Spy
    Written by Echo Technologies, this free tool will allow you to look at the internal data on a SharePoint site and compare the effects of making a change without changing the actual data. This tool is really helpful if you are writing a program that is manipulating data on a SharePoint list, and you don't want to have to change the data each time. You can also use this tool to compare settings between sites, views and lists to help troubleshoot configuration problems.

Tuesday, November 18, 2008

Oh brother...another 419 scam



The 419 scam is also known as the Nigerian Letter Fraud and the Advance Fee Fraud. This posting from the FBI discusses this and other common e-mail fraud schemes.

Here we go again...

Yesterday I received a letter via e-mail from a sad sack called Mrs. Susan Morgan. Basically, she's a wealthy widow who lives in Kuwait (with an e-mail address from Yahoo! China and a mailing address from the Ivory Coast{Côte d'Ivoire}), and she's a born-again Christian. Apparently she's dying, and she has no heirs except her late husband's relatives. She doesn't want to leave the money to the late husband's relatives because they're heathens (my words, not hers). Well, it's my lucky day! She wants to leave her money to me (she thinks I'm a church) because she knows that I'll use it for Christian causes.

Scam baiting is a way that people try to scam the scammer by pretending to be a victim in order to waste the scammer's time or to gather information about the scammer so legal action can be taken.

The site 419 Eater contains accounts of people who engaged in scam baiting. Dateline NBC on US network NBC has done investigative pieces on Advance Fee Frauds by performing scam baiting.


I would think that by now, people would realize that these e-mails are ludicrous and they would either disregard the e-mails or (if they're in a playful mood) engage in a little scam baiting. Unfortunately, there are still people who let their greed override their common sense, as demonstrated in this recent story about a woman who lost $400,000 to scammers.

Why am I discussing this on a technical education blog? As an IT professional, you may have to play the role as "police officer" to your company's IT resources. In that role, one of your job duties will be to warn your user base of viruses, security threats, hoaxes, and e-mail scams. It may seem like it's a waste of time to send warnings about e-mail scams to your user base because most people would realize it's a scam, but the warnings are for those who will throw common sense out the window for an imaginary chance at the big prize.

Although you are doing someone a favor by warning them about potentially losing their money, you are actually practicing due diligence for protecting your company's IT infrastructure. Someone who's corresponding with these scammers (whether the person is making serious inquiries or if the person is scam baiting) using your company resources can put your infrastructure at risk since SMTP requests are traceable.

Note: When you tell your users to ignore the "advance fee fraud" e-mails, also tell your users not to engage in scam baiting using the company's resources. You don't want your servers and network clogged with traffic not related to work.

Saturday, November 8, 2008

Scribd - YouTube for Published Documents



A few months ago, I stumbled upon Scribd (http://www.scribd.com), a site where authors can publish their writings. I found it in a roundabout way, actually.

I wasn't looking for a way to publish my documents (I have two web servers where I can house my documents, and I have Google Docs on my Google account) - I was looking for an essay on network security, and the search engine brought me to Scribd. Once I was there, Scribd piqued my interest.

General Information About the Company


Scribd was founded in 2006 by Trip Adler, Jared Friedman, and Tikhon Bernstam on a budget of a mere $12,000. As of 2008, they have received over $3 million dollars in funding. Scribd's mission was to provide a way for people (primarily authors) to host shared documents on the web. Scribd also partners with publishing companies so publishers can use the site for publishing content.

iPaper


In 2008, Scribd launched iPaper, a Flash-based interface which allows a user to embed documents in webpages and blogs. For example, if you have a website or blog and you don't want the reader to exit your site, you can embed the document in your webpage or blog page (like you can with YouTube). Scribd also launched an API that developers can use to implement the functionality in the developers' own site. The marketing point on iPaper is it eliminates the need for readers to have other readers on their machine, such as the Adobe Acrobat Reader and the Microsoft Office Readers.

Here's an example of embedding iPaper in the site:
TCP/IP

An Analysis of Scribd


There are a number of things that impressed me about the product.

  • It's free to use. I don't profit from my blog or my web site, and all of the costs for my web servers are out-of-pocket. Therefore, finding ways to control my costs is important to me. I can register to use the site for free, and I can host my writings for free.

  • I have more space on my web servers. Because my documents are being hosted on a third party site, I can utilize the space on my web servers for other things, such as a download site for my applications.

  • My documents reach a larger audience. Before using Scribd, I wasn't getting many hits from my documents. They were only being read if someone accessed it through my blog or if someone stumbled upon it from a Google search. Since publishing my documents one week ago, my readership rate doubled, and it's still growing.

  • If you are looking to make additional money with your documents, you can use their "Ads for PDF" program that will embed ads in your documents, and you can also earn ad revenue from your site if you embed iPaper documents on your site. Visit their site for more details.



DMCA: Digital Millenium Copyright Act - full explanation


There are some things that need to be addressed, though.

  • Like YouTube, Scribd has experienced some legal problems with their user base violating the DMCA (ex: users uploading PDF versions of copyrighted textbooks). However, Scribd has taken measures to remove content that violates copyrights, such as introducting copyright filters.

  • It appears that the iPaper control doesn't play nicely with some of the documents that are uploaded. For example, I noticed that some of the documents had unreadable characters that rendered through iPaper, but if I downloaded the document to my local machine as the document's native format (ex: PDF), the document renders fine on my local machine using the document's native format reader (ex: Adobe Acrobat).



Here is some additional information about Scribd

  • I haven't tried this myself (which is why I categorized this as an "unknown"), but I have read reports from various users that Scribd's iPaper doesn't work well on mobile devices such as the iPhone. If you have a chance to test this on a mobile device, please let me know.

  • If you are going to use Scribd as a hosting solution for documents that you've written, make sure you have a backup strategy in place. For example, I have my documents on local media (my personal machine and flash drives) as well as Scribd.

  • It's not a true document sharing tool by definition because you can't edit the content of your documents on the server once they are published. As a workaround, you can work on the document on your local machine and upload the latest changes to Scribd without losing your original statistics. While some authors critiqued this, I didn't really think it was a downside because I view Scribd as a content hosting server (like YouTube) rather than a document sharing tool (like SharePoint).



Why I Started Using Scribd


The main reason why I started using Scribd was cost. I wanted to make more room on my web servers without having to pay for more disk space, and Scribd was a tool that I can use to host documents that I've written at the lowest possible cost. Another reason was a way to build my career portfolio. Based on what I've seen in my web access statistics, my documents on Linux that I've written were reaching a healthy audience, but my other documents weren't getting as many hits. I wanted to be able to reach a larger audience, and Scribd was a tool that helped me do so.


Like Scribd, YouTube was intended for use as a site where people can publish their videos. Agents and producers search through YouTube to find new talent for free, and television networks use YouTube to publish their content rather than using their own web servers.

The intended use for MySpace was to provide a social network for musicians. MySpace has become a social network tool for users from all walks of life, including celebrities. MySpace is also been used by professional models as a way to publish their portfolio. Agents, producers and magazine editors (such as Playboy) search through MySpace to find new talent for free.


The Future of Scribd


I think that the site is going to be the next best thing because others found and will continue to find other uses for the site (ex: YouTube and MySpace). For example, the current economy is causing businesses to rethink how to spend their dollars. To help save money, recruiters are using Scribd to search for resumes for free, rather than pay fees to the mainstream job boards. I can also see publishers beginning to use Scribd to publish e-books for their company rather than publish the e-books on their own web servers.

Additional Sources:
The Killimanjaro Corporation v. Scribd.com et al. Retrieved 08 November 2008.
Wikipedia. Scribd. Retrieved 08 November 2008.
Gilbertson, Scott. iPaper: a Simple Way to View and Share Documents on the Web. WebMonkey. 20 February 2008. Retrieved 08 November 2008.

Thursday, November 6, 2008

Two years on, Raketu is getting better and better



Over two years ago, Raketu was released to the general public. I wrote a review of the product when it was initially released, which you can find here.


SIP - Session Initiation Protocol. This is the signalling protocol often used in VoIP networks.

For a more technical explanation:


There has been many changes made since I wrote that review:

  • They have IPTV featuring international programming

  • They improved their podcast support

  • Raketu RakOut works on Mac and Linux

  • They dramatically improved their user interface

  • They created two new services: RakOut WebPhone (allows user to make computer-to-phone calls from a web browser) and RakIn/RakSIP. RakIn/RakSIP is probably one of the biggest improvements to the product, since this capability allows Raketu users with a SIP device to connect to the Raketu service and receive telephone calls.

  • Raketu recently launched VideoCalling service, which allows users to conduct PC-to-PC phone calls (voice and/or video).



The most important development in this product, in my opinion, is the RakIn/RakSIP. In relation to VoIP, one of the selling points of Raketu was it had some of the lowest calling rates in the market today. However, since Raketu didn't support incoming calls, they couldn't really compete with some of the other VoIP providers (ex: Skype, Vonage, MagicJack). Now that they support incoming calls, they easily become a true competitor in the VoIP market.


SO/HO - Small Office Home Office


Although Raketu's target audience is the home user, it can also be used as a viable option for a SO/HO business. For example: a computer consulting business with about 2-3 employees may have clients outside the state, or even around the world. While there may be a need to travel to a client's site, it can get very costly. The RakOut WebPhone can be used for video conferencing between the client and the business, provided that both the client and the business have video cameras on their PCs. For the one-time cost of SIP-compatible phones and the monthly cost of high-speed Internet service, the RakIn/RakSIP service can be used in lieu of regular phone service. The monthly costs could be less expensive than standard phone service. If the business gets a SIP-compatible mobile phone (iPhone supports SIP clients like Raketu), the business can integrate their mobile services with Raketu, which could eliminate the cost of additional SIP-compatible phones for the static location.

I am quite pleased with the improvements that Raketu has implemented in their product. I am also impressed with their customer service. This company really listens to their customers and takes their suggestions into consideration in their product development. Raketu is a viable alternative to standard land-line phone service.

Monday, November 3, 2008

Choosing the Right School - the 2008 Edition


Digg!

Before continuing with this article, please read the following two posts that I've made in the past regarding this subject:
Choosing the Right School
Choosing the Right School - Revisited

There is a reason why I'm revisiting this subject. Right now, we are in shaky economic times, and many people are looking to school for training in a career that can (at least) get them a job and pay the bills. One of the trends that I'm seeing right now is students who are just choosing a certain major because they believe that it will get them a job that will allow them to support their family. A number of these students are choosing Information Technology majors. Many of these students don't really care for the field of study, nor is it something that they really want to do for the rest of their lives. They're choosing this field because they believe that it's the field that can get them a job that will pay them a living wage.

I'm about to post an opinion that will probably be controversial - those students are wasting their time and money.

Let me explain.

I do understand that the market is tight, and many people are losing their jobs. Many people are also underemployed (either working a part-time job as the primary employment or they are working a low paying job like a discount department store or a fast food restaurant because they can't find a job in their field that pays a living wage).

I do support their decision to go to school to better their career. However, if the only reason that someone chooses an Information Technology major is to better their career, then I don't support their decision, and here's why:

  • School is a major investment in time and money. Depending on the school, a two-year degree costs between $8,000 - $40,000. That's a lot of money to spend on something that doesn't appeal to you, especially during these lean times. If you are getting federal loans for your education, you still have to pay them back regardless of whether you liked your educational experience or not.

  • Part of success in school is choosing a field that interests you. I'm going to use myself as an example. I like to read historical biographies, but analyzing fictional literature bores the Hades out of me. I really don't give a whoo-ha about the symbolism that the author of the story is using and the messages that s/he's conveying in the story. Since I think that analyzing literature is boring, I never really put in the effort in those classes; I only did enough work that would get me a B-. Now, imagine if I decided to go back to school and study literature because it's a field that could get me a job. It would pain me to go to class. In fact, I'd probably go enough times and do enough work to get a passing grade. The problem is, in leaner economic times, the job market is much more competitive. My lower QPA/GPA will hold me back from interships that will get me the experience that employers want. Just say I'm lucky enough to find a job in the field. I wouldn't be happy at that job because it's not what I want to do.
    Now let's go back to the student - if it's a field that s/he's remotely interested in, then that's good. As s/he takes classes, s/he may grow to like the field more. However, if it's a field that doesn't interest him/her, the chance of the student dropping out is high, and if the student stays the course, the chance of the student doing well academically is low.

  • Another part of success in school is choosing a field in which you can excel. I will use myself as an example again. Maths and sciences were my forte. Fine art is not. I always say that I'm lucky that I can draw a straight line. If I decide to go back to school for multimedia, which requires a number of art classes, I wouldn't do very well because I don't have the artistic talent that many others have. Instructors will give me low grades for my work. If the instructor just passes me along, I won't have a good chance at finding a job because there are numerous people out there that are more talented than I am. Let's get back to the student - if the person doesn't have the talent for that field, it's not for that person. If the person is not very good at mathematics, then computer programming is not for them.



So what is a person to do? Again, school is a major investment in time and money. While going back to school is a good thing for your career, don't let "getting a better job" be your only reason to go back to school.

Sunday, November 2, 2008

A Historical Election Day in the US (2008)


Digg!

Regardless of who wins the election, history is about to be made in the United States. We are either going to be getting our first man of color as President, or we are going to get our first female Vice-President (and our eldest elected President should that party win).


About two years ago, Professor Ed Felton from Princeton University and 2 graduate students found ways to hack the Diebold voting machines.

Election day in the United States is interesting for technology since USA has been using paperless voting machines for about 3 years now. Again, the focus of discussion on many radio and television news programs is the "hackability" the voting machines.

If you're interested in how the hack works, here is a video demonstrating the hacking:



For a little humor about hacking the voting machines, here's a funny satire video post on hacking voting machines.


I've written about this topic on the blog during the 2006 election, and the things that I've discussed then seem to be relevant today.

Saturday, November 1, 2008

C# Tutorial - Combine Multiple Word Documents into One Word Document


Digg!


Click the link to download the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.




One of the tasks that I have to do at work is combine a few Word documents into one Word document, convert it to a PDF, and publish the PDF on the web. I really didn't like to manually combine the documents, so I wrote a quick program that allows me to combine the documents into one document.

Overview


The command-line program uses the Microsoft.Office.Core library to reference Microsoft Word.

In a nutshell, the program does the following:

  • It gets the values that the person entered at the command line

  • It opens a new Microsoft Word file

  • It loops through the paramters, opens each file, and appends the file to the new Microsoft Word file

  • It saves the new file



Highlights


Using an "alias" in the using statement
A quick trick that you can do when referencing a library is assigning a quick "alias". You can then reference the alias throughout your program. Here is an example of how to use an alias in the using statement, and here is an example of referencing the alias:

using WORD = Microsoft.Office.Interop.Word;
:
object sectionBreak = WORD.WdBreakType.wdSectionBreakNextPage;


Capturing the Files to Combine
In order to find out which files to combine, we need to start from position 2 in the array to find out which files we need to combine. What I did in the code is starting from position 2 in the parameters, I build a new array (line 22 in the source). Here is the code snippet:

String[] parms = new String[args.Length - 2]; // subtract 2 - the parm starts @ pos 2, not pos 0
for (int x = 0; x < parms.Length; x++)
{
 parms[x] = args[x + 2];
}


Setting Up the Word Document
Below is the code snippet (line 29 in the source):

// Set up the word object
object template = @"Normal.dot";
String fullName = destDir + "\\" + destFile;
//object fname = @"F:\temp\new_file.doc";
object fname = fullName;
object missing = System.Type.Missing;
//object pageBreak = WORD.WdBreakType.wdPageBreak;
object sectionBreak = WORD.WdBreakType.wdSectionBreakNextPage;

// Create Word application
WORD._Application app = new WORD.Application();

In the first 5 lines, I am setting up variables for the following:

  • The Word template to use

  • The destination (new) file. Note that I have used double backslashes, because the backslash is an escape sequence character in C#. If I used one backslash, I would get a run-time error.

  • A reference to the type of section break in Word. Note that if you want a page break instead of a section break, make a reference to the page break instead.


The final code line creates an instance of the actual Word application.

The Process of Appending the Document
The code to append the documents into one document starts from line 40 in the source. Below is the code snippet:

try
{
  // Create new file
  WORD._Document doc = app.Documents.Add(ref template, ref missing, ref missing, ref missing);

  WORD.Selection selection = app.Selection;

  // Write text
  //selection.TypeText("Write something...");
  //selection.TypeParagraph();

  // New page
  //selection.InsertBreak(ref pageBreak);

  // Insert file
  String insertFile = "";
  for (int y = 0; y < parms.Length; y++)
  {
    insertFile = destDir + "\\" + parms[y];
    selection.InsertFile(insertFile, ref missing, ref missing, ref missing, ref missing);
    //selection.InsertBreak(ref pageBreak);
    selection.InsertBreak(ref sectionBreak);
  }

  // SaveAs
  doc.SaveAs(ref fname, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
}
finally
{
  // Close Word application
  app.Quit(ref missing, ref missing, ref missing);
}


Let me explain various code blocks:

  // Create new file
  WORD._Document doc = app.Documents.Add(ref template, ref missing, ref missing, ref missing);

  WORD.Selection selection = app.Selection;

This code block creates a new document and sets up the cursor.


    insertFile = destDir + "\\" + parms[y];
    selection.InsertFile(insertFile, ref missing, ref missing, ref missing, ref missing);
    //selection.InsertBreak(ref pageBreak);
    selection.InsertBreak(ref sectionBreak);

This code inserts the contents of the file in our new document. Then, it inserts a section break. Again, if you want to enter a page break instead of a section break, you will need to reference the page break instead of the section break. Also note that you don't have to insert any breaks if you don't want to.


  doc.SaveAs(ref fname, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

This line saves the new document.

This code has a boat load of possibilities. For example, if your final application is required to write text to a new Word document, this code will work. Note that you'll have to comment out the logic that reads the contents of the other Word files, and you'll have to uncomment and modify the logic that writes text (line 47 in the source)

// Write text
//selection.TypeText("Write something...");
//selection.TypeParagraph();



If you have any questions, please post a comment or just ask. :)


Quick Note About the Program: If you are using spaces in the names (ex: C:\documents and settings), you must surround the values with double quotes (ex: "C:\documents and settings") because the C# command prompt treats each space-delimited value as a parameter.

Wednesday, October 29, 2008

Spotlight on a Good Example of an On-Line Portfolio


Digg!


To get lost in a few interesting games as well as learn a few tips and techniques of graphics programming, visit F. Permadi's site

http://www.permadi.com


While I was looking for information on how to do something in Flash MX 2004 about a year ago, I stumbled on a web site from F. Permadi. This site contains some really good examples of "graphics programming with a computer science twist", as well as well-explained tutorials on Flash and HTML/CSS.

What I found interesting about the site was it was a good example of an on-line career portfolio. I would like to focus on why this site is a good example of a career portfolio.

  • He Explains Exactly What He Does in the "About" Section

    One of the things that experienced entrepreneurs teach entrepreneurs-to-be and salespeople is the "elevator pitch". It means "tell me enough information about yourself from the time we enter the elevator to the time I get off on my floor". His "About" section is a good example of the "elevator pitch": he tells the reader a little bit about himself, he tells the reader his skill set, he tells the reader about his education, and he gives a way to contact him.

  • He Publishes Examples of His Work, Including the Source Code and Tutorials

    Just like artists put examples of their work in their portfolios, he has published examples of his own work on the site. Note that he has also published tutorials and source code to some of the applications to demonstrate that he really did do the work. If you're an IT professional publishing your portfolio, be sure to publish examples demonstrating that you have done the work or you know how to do the work.

  • He Publishes Information About His News and Awards

    In a career portfolio, don't be afraid to broadcast your accomplishments! In the "News and Awards" section, he noted the recognition that he received in various publications for his work. If you have a blog, and it was chosen to be a "Blog of Note", publish that news. If you have won awards for your work, mention them.

  • The Site is Professional

    I cannot emphasize the importance of a professional looking site. It demonstrates to the reader that the person is serious about his or her profession. If you are going to develop an on-line portfolio, look into taking the time to make the site somewhat appealing. If you are not a creative dynamo, or if you are not a web developer, recruit a friend to help you. Another alternative is to use a pre-fabricated site like Blogger as your front-end user interface, and have links to your projects hosted on a web or file server.



If you're a graphics programmer looking for tips and techniques, visit his site. If you're a student looking for good examples of career portfolios, visit his site.

Networking Students: Do You Know Your Line Signal Levels?


Digg!

Telecommunications and networking students usually need to learn the intricacies of cabling, such as DS-1/T1 lines. To help break up the monotony of lectures, I created a game (in Flash MX 2004) that I have the students play in class to help them learn the line information, such as the bit rate of lines and how many of the smaller lines does it take to make the line.

If you are a telecom/networking student, give the game a try!






The only reason why I didn't publish it because Flash MX 2004 is a few versions old (it's up to Adobe Flash CS4). However, if you are interested in the source, please drop a comment to this blog, and I'll publish the source.

Monday, October 27, 2008

C# and SharePoint 2007 Tutorial - Getting the Total Responses for All the Surveys on a SharePoint Site


Click the link to download the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.




A project that I'm currently working on for my CIO is to create more robust reports from surveys created in SharePoint 2007. I'm using a SQL Report Server Project to build these reports from the data entered on a SharePoint survey. In order to be able to create a report, the SharePoint survey needs to have responses. I really didn't want to spend time manually checking each survey to see whether it has responses. I wrote a program using C# to automatically check the surveys on the SharePoint site and return the item counts (responses) to me via e-mail.

Overview


The program uses the Microsoft.SharePoint library to access the SharePoint site, and it uses the System.Net.Mail library to send the e-mail. To keep the program flexible, I keep the "to e-mail", "from e-mail", SharePoint site URL, and SMTP server name in the app.config file. That way, if there's a change to any addresses, I can just change the config file instead of having to change and to recompile any code.

In a nutshell, the program does the following:

  • It gets the values from the app.config file

  • It opens the SharePoint site

  • It loops through the Lists collection of the site and returns the item count (responses)

  • Sends the results to the e-mail address referenced in the "to e-mail" element of app.config



Highlights


Traversing through the Lists collection on the SharePoint site
Starting from line 25 in the source (Program.cs), it uses the SPSite class and the SPWeb class (Microsoft.SharePoint) to open the site (as referenced in app.config). Using a foreach loop, it looks at each list in the collection and returns the value in the Items property of the list, which is the total number of responses for the survey. Here is the code snippet:


using (SPSite site = new SPSite(strURL))
{
  using (SPWeb web = site.OpenWeb())
  {
    foreach (SPList list in web.Lists)
    {
      msgSB.Append(list.Title);
      msgSB.Append(" - ");
      SPListItemCollection items = list.Items;
      msgSB.Append("Total items: " + items.Count);
      msgSB.Append("\r\n");
      msgSB.Append("\r\n");
    }
  }
}


Note that msgSB is an instance of the StringBuilder class, and I am recording all the results in this instance.


If your SMTP server requires a specific ID and password for authentication, you can use the System.Net.NetworkCredential class to specify the ID and password. Here is a code snippet on how to set up your SmtpClient instance to use the specific credentials:


System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(ID, password, domain);
smtpClient.Credentials = credentials;


If you are going to use this method, please be aware of some security precautions, such as not storing the ID, password, and domain in clear view of the naked eye. For example, if you want to store this information in the app.config file: encrypt the values, put the encrypted values in the app.config file, and use the code to decrypt the values.

Sending an E-Mail
The MailMessage class sends the e-mail. However, I wouldn't be able to send an e-mail without referencing an SMTP server. The SmtpClient class is used to "set up" the SMTP server. Below is the code snippet, found on line 42 in the source.


String message = msgSB.ToString();
MailMessage mail = new MailMessage(fromEmail, toEmail, subject, message);
String mailServer = Properties.Settings.Default.mailServer;
SmtpClient emailClient = new SmtpClient(mailServer);
emailClient.UseDefaultCredentials = true;
emailClient.Send(mail);


Note that I'm converting the StringBuilder instance (which contains the results) into a string. Also note that the UseDefaultCredentials property is set to true, which means that the program will use the current logged in user's credentials to authenticate against the SMTP server. One of the ways that network administrators prevent hackers from hijacking their SMTP server to use for sending spoof e-mails is they configure the SMTP server to require authentication.

The app.config file


Since it's possible that addresses can change due to machine upgrades and domain name changes, I stored the following four values in the app.config file:

  • <toEmailAddress> - The e-mail address of the person who should receive the report

  • <fromEmailAddress&; - The e-mail address of the person of the "sender". This is typically a "webmaster" address or a generic "SharePoint administrator's" e-mail address

  • <surveyURL> - The ROOT URL where the surveys are located. For example, if your surveys are on site http://bogussite/surveys, enter http://bogussite/surveys.

  • <mailServer> - The name of the SMTP server



In the source code, I wrote an explanation of what values should be in each element. You will need to replace that information with the actual values.
Here is an example configuration snippet of the app.config file:


<SurveyListCount.Properties.Settings>
  <setting name="toEmailAddr" serializeAs="String">
    <value>jennifer.lewis@mymwalimu.org</value>
  </setting>
  <setting name="fromEmailAddr" serializeAs="String">
    <value>webmaster@bogus.com</value>
  </setting>
  <setting name="surveyURL" serializeAs="String">
     <value>http://SomeSharePointSite/SurveysSubsite</value>
  </setting>
  <setting name="mailServer" serializeAs="String">
    <value>SMTP.BogusSite.com</value>
  </setting>
</SurveyListCount.Properties.Settings>




Before Using the Code for Your Own Solution:

  • The compiled program (binary) must reside on the same machine where SharePoint 2007 is installed, or you will get errors.

  • Ideally, you want to have your surveys in a separate subsite of your site collection. If you have other lists in your site collection or subsites, the program will pick up the item counts of those lists as well.

  • If you want the program to run at a certain time (ex: every Wednesday evening), you will need to use Windows Scheduler to schedule the binary to run automatically.


Wednesday, October 22, 2008

C# Tutorial - Jewelry Pricing Calculator


Click the link to download the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.




One of the things that I do on the side is make jewelry. In fact, I'm in the process of starting a jewelry business. In order to sell the jewelry, I need to determine what to charge for each piece. I decided to make myself a tool (using C#) that I can use to find out what to charge for jewelry.

In a nutshell, users of this application enters the cost of materials, the hourly rate, and the number of hours it took to make the piece. Once that information is entered, the tool will calculate the minimum price to charge and the maximum price to charge based on an equation used for determining MSRP (Manufacturer's Suggested Retail Price).



The application also has checks to make sure that the user entered decimal values in the fields, and since this is a multi-form application, it has checks to make sure that the form is closed before it attempts to open the form.

The application uses a variety of different components, such as:

  • String formatting

  • Toolbar and menu

  • Timer

  • Rich Text Box



Here are some code snippets highlighting some of the things that the application does.
Using the Timer to make a "rotating banner"
On the main application form (Form1.cs), I created a "banner" displaying directions on how to use the application. In order to do the rotating banner, I used the timer control, the label control, and a string array containing the messages.
1) I defined a label on the form (called lblHelp).
2) I added a Timer object on the form. I configured the following properties:

  • Enabled = true

  • Interval = 5000 (5 seconds)


3) In the program (line 14), I defined a string array containing the messages. I also defined a variable to keep track of the current position.


int pos = 0;
string[] textToDisplay = new string[] { "Enter the total cost of materials used for the project. For example, if you purchased a lot of 20 beads for $5.00, and you used 10 beads, the total cost would be $2.50", "Enter the hourly wage for the person who made the jewelry", "Enter the total hours it took to make the project. Round up to the nearest 15 minutes. For example, if the project took you 38 minutes, round it to 45 minutes.", "Select Action - Calculate from the menu, or click the calculator button at the top of the screen." };


4) In the Tick event of the timer (line 185), I added the following code to change the message in the label:


pos++;
if (pos == textToDisplay.Length)
{
  pos = 0;
}
lblHelp.Text = textToDisplay[pos];


In this snippet, I am changing the position of the array. In order to prevent the application from "crashing" because the position of the array is bigger than the array, I check to see if pos is equal to the number of elements in the array (textToDisplay[pos]). If it is equal, then I reset the position to 0. Remember that arrays in C# are base 0 arrays, which means that the first element in the array is position 0. Finally, I set the value of the label to the value in the current position of the array.

Getting the Application Version
One of the things that I wanted to display in the about form (frmAbout.cs) was the current version of the application. Using the System.Diagnostics.FileVersionInfo class, I can get the version of any file. In this case, I want to get the version of the executable file that's created from this project. Here is the snippet (line 17):


System.Diagnostics.FileVersionInfo thisVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo("JewelryPricingCalculator.exe");




Alternative to using the foreach loop for checking whether a form is open in C#
Forms in VB .NET have a slick property called Visible that will indicate whether a form is visible (open) or not. Remember that Microsoft developed the .NET architecture for flexibility. If you import the Microsoft.VisualBasic.dll in your project and you make a reference to the dll (using Microsoft.VisualBasic;), you can utilize the Visible property in C#. However, with C#, you still have to define an instance of the form. Here is an example:


Form2 f = new Form2();
if (f.Visible == true)
{
  f.Focus();
}
else
{
  f.Show();
}




Checking to see if a form is already open
Since this is a multi-form application, I wanted to check whether the form is already open before I attempt to open the form. In order to do this (in Form1.cs), I use a foreach loop through the Application.OpenForms object. Here is the code snippet (line 164) determining whether the help form is already open:


bool helpOpen = false;
frmHelp helpF = new frmHelp();
foreach (Form a in Application.OpenForms)
{
  if (a is frmHelp)
  {
    helpOpen = true;
    break;
  }
}

if (helpOpen)
{
  helpF.Focus();
}
else
{
  helpF.Show();
}



As you'll noticed in this example (versus the previously published examples), I took user experience into consideration. Even so, there's always more that can be done. If you are going to experiment with this code, here are some suggested things to try:

  • Using the Crystal Reports component in Visual Studio, create a report of the results and allow the user to print that report

  • Use the app.config file to control certain numbers and constants, such as overhead markup percentages and cost markup numbers.

  • Using this application as a foundation, create a database back-end and use the application as the interface to a database containing your prices.



Enjoy!


Supplemental Information: The Equation
The equation used to calculate the retail price for jewelry is: total cost + labor + overhead.

To calculate the total cost, you take the cost of the materials used for the piece and multiply that number by 2 (for retail pricing) or by 1.4 (for wholesale pricing). Example: if you bought a lot of 20 beads for $5.00, and you used 10 beads, your total cost is $2.50 * 2 = $5.00 (for retail). Note that some people take the cost of the lot of beads into consideration for the total cost, ex: $5.00 * 2 = $10.00 (for retail), since you may have leftover beads that you can't reuse in other projects.

To calculate the labor, you multiply the hourly rate by the hours worked. Typically, you want to round up to the quarter hour. For example, if your hourly rate is $10.00, and it took you 20 minutes to create a piece, you multiply $10 * .5 (30 minutes) = $5.00.

To calculate overhead (rent, electricity, consumables, travel time, etc), you can do one of two equations:
- For minimum overhead, you take the total cost + labor and multiply it by .20.
- For maximum overhead, you take the total cost + labor and multiply it by .25.

Tuesday, October 21, 2008

C# Tutorial - Filter Contents of a File Containing a Word or Phrase


Click the link to download the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.




If any of you ever had to filter through Internet server logs to troubleshoot a problem (ex: every time someone accesses somepage.aspx, the server returns an HTTP error 500), you can understand how painful it can be - especially if your log has a lot of transactions in the file. I wrote this "quick-and-dirty" application to allow me to just filter out the lines that I'm looking for, and save the results to another file.
This application uses the System.IO library for file processing. It also uses the OpenFileDialog and SaveFileDialog objects to allow a person to select a file and save a file.

In a nutshell, this is what the application does:

  • It allows a user to type in a file name or select a file (using the OpenFileDialog object)

  • It allows the user to enter a word or phrase to look for (or leave the field blank for all the data)

  • It uses the System.IO object FileInfo to check the file size to see if it's greater than 5MB. (If it is, it warns the user that the file is large and asks if s/he wants to continue)

  • It uses the System.IO classes StreamReader and FileInfo to open and read the contents of the file

  • It uses the IndexOf function of the string class to find out whether the line contains the entered word or phrase (if one was entered)

  • For better memory management, it uses the StringBuilder to build the results

  • For saving the contents of the file, it uses the SaveFileDialog to allow the user to select where to save the contents. Then, it uses the System.IO classes Stream and StreamWriter to write the output to a file.



Here are some code snippets highlighting some of the things the application does:
Checking the file size and asking the user if s/he wants to continue
While I was using this, I found that large files really took awhile to load in the application. What I wanted to do to improve the user experience is to warn the user if s/he is trying to open a file that is greater than 5MB. I wanted to make sure that the user still wanted to continue. Here is the code snippet (found in Line 71 in the source):


// Check the size of the file
FileInfo fi = new FileInfo(txtFileName.Text);
// Warn user that the file is huge if file > 5 M
if (fi.Length > 5000000)
{
  DialogResult answer;
  answer = MessageBox.Show("The file you selected is large and may take some time to load. Are you sure you want to open this file", "Confirm Open Large File", MessageBoxButtons.YesNo);
  if (answer.ToString() == "No")
  {
    txtFileName.Focus();
    return;
  }
}


In this snippet, I am using the Length property of the FileInfo class to determine the size of the file. Since it returns the value in bytes, I need to check the byte size. Since I'm giving the user an "are you sure" type box, I need to be able to capture the results from the MessageBox. The DialogResult class is what the MessageBox returns when an action is taken (a button is clicked).
Notice that have a return statement. For you VB .NET programmers, this is the equivalent of an Exit Sub statement. Rather than put the code in a massive if-else loop, I just add the return statement to exit from the function if the user does not want to continue.

Setting the Filters for the OpenFileDialog and SaveFileDialog
By default, no filters are set. So when your user opens the dialog box, nothing will show up under the "File Type". In order to set the filters for text files only, do the following:


FileDialog.Filter = "Text Files|*.txt";


Where FileDialog is the instance of your OpenFileDialog or SaveFileDialog. The first part is the text to display in the drop-down box. The second part is the files to display that match the extension. Each section is separated by a pipe (|).
If you want to do multiple types, do the following:


FileDialog.Filter = "All Files|*.*|Text Files|*.txt";



Writing the contents of a text box to a file
I wanted to be able to write the filtered results to a file in case I need that file for other applications or purposes. Here is the code snippet (found on line 53 in the source):


// Get the contents of the text file
Stream saveStream = sfdContent.OpenFile();
StreamWriter sw = new StreamWriter(saveStream);
sw.Write(txtResults.Text);
sw.Close();


In this snippet, I am using the OpenFile function of the SaveFileDialog class (the instance is called sfdContent) to get the value entered by the user. I am then using the System.IO classes Stream and StreamWriter to take the contents of the text box and write it to a file.

I have placed a link to the source code for you to use to help with your studies. If you are looking for more practice, here are some suggestions for improving the application:

  • Make a progress bar so it will display when someone tries to open a large file

  • Give users the ability to change the "skin" of the application

  • Add a menu

  • Add an "About" option with release notes

  • Add a splash screen

  • Change the look and feel of the screen

Saturday, October 18, 2008

Spotlight on an Example of Student Entrepreneurship

In previous articles, Getting a Job in a Tough Economy and Beating the Catch-22 of Aspiring Digitheads, I mention entrepreneurship as a way to gain experience in the field. In this article, I want to show you an example of two students who are using entrepreneurship as a way to gain experience.

For assistance with your networking and PC needs, or for networking/PC tips and , visit M & J PC Consulting

http://www.mjpcconsulting.com

Jonathan Geyer and Mike McCoy are two students of mine who have started M & J PC Consulting a few years ago. The company specializes in providing networking and PC solutions for both home and business users. As an added bonus, their site also contains free networking and PC tips and techniques to the general public.

From a student's perspective, Mike and Jon's efforts are a good example of "selling yourself" to the job market.

  • They offer services and explain what they have done


    If someone is looking at either one of them as an employee or contracting candidate, one has an idea of what Mike and Jon has done in networking and PC work. As someone who has had experience with making decisions on hiring personnel, a pet hate of mine is technical interviews that ask "test questions" rather than ask questions to demonstrate experience (example question: "In a Class C network address, which part of the address is the network address?" vs. "Have you ever had to subnet a network, and if so, demonstrate the process that you went through to do this"). Being able to answer "test questions" doesn't necessary demonstrate to me that one can do the job; it only demonstrates that one knows how to study and memorize. I'm more interested in seeing what the person can do and has done.

  • Having the business highlights their secondary skills

    Non-IT companies who are looking for IT personnel don't want "digitheads" only. They want people who also have a good understanding of how business works so these people can provide IT solutions that will help grow a business. The employees must also have good oral and written communication skills, as well as good customer service skills. Having their own company demonstrates to employers and customers that Mike and Jon understands general business rules, the needs and limitations of business, and the strategies to help a business grow. They also highlight their other secondary skills by explaining that much of their business comes from recommendations. If they didn't have the communication or customer service skills, they would probably not be successful.

  • Their site can be used as part of their career portfolio

    The purpose of a career portfolio is to show potential employers and customers what you can do. The site highlights a number of skills that Mike and Jon both have.

  • They are keeping their options open regarding employment

    In my opinion, people who limit themselves with their employment options (location, employment status, type of company) won't make as much strides as someone who is more open to their employment options. Having their own business keeps Mike and Jon's employment options open. They can run the business full time, or they can run the business part time and supplement their income in other ways. They can also relocate if they so desire.



If you are student who is looking for help on a networking or PC topic, an example of a career portfolio, or an example of starting a business, visit their site. If you are a business looking for IT networking contractors, I can attest that both Mike and Jon are experienced in PC and networking and they both do a fantastic job.