Category: C#.NET

  • CSV Parser

    For some of my work, I work on data importers and other different tasks which require dealing with CSV and tab delimited files which can often be very challenging to parse. I was sick of rolling my own csv/tab delimted parser, so I went ahead and found one that worked very well on CodeProject simply […]

  • try..catch Usage – Unused Variable Warning

    Elminating the unused variable warning for a declaration in the catch block is very easy because you don’t need to assign to a variable. See the below code for an example. try { doSomething(); }catch (Exception) { logError(); } Note: you should always log an exception if it isn’t expected. For example, for any IO […]

  • Stopping a System.Threading.Timer

    Stopping a System.Threading.Timer isn’t very well covered in the MSDN documentation. We need to use the Change Method which accepts two integers. Please note that it is possible that a few callbacks can be potentially queued and called after you have stopped the timer. This is because the callback of the System.Threading.Timer uses worker threads. […]

  • Windows Service – Marked For Deletion

    Windows Services,especially managed .NET ones , can be extremely difficult to deploy if not done correct initially. Errors, of course, can also be very difficult to diagnose if theres a problem immediately after the server starts. Occasionally, as a developer you need to uninstall the service whether it be through sc delete, or installutil /u […]

  • Run a Single Instance of An Application (.NET)

    Occasionally, as a software developer you want to restrict a user to only allow them to run one instance of an application on their machine. The reasons why vary dramatically, but often it is because it could make large system changes, maybe their is some business reason, or perhaps it just doesn’t make sense. Restricting […]

  • How to Minimize Application to Tray

    I’m not sure how many times I have been someone ask for help on the MSDN forums, email me, or come over and ask me in the case of coworkers. The steps to have an application minimized to tray are very simple. Create .NET Windows Application. Create .NET application. Add Tray Notifcation Icon to Windows […]

  • How to Get Path of Running Application in C#

    Getting the path of the running application is really simple, and is pretty important if you allow the user to install the application anywhere (which you really should do!) I’ve just included the way to do it for windows forms, but it isn’t that hard to adopt to other situations. using System.IO; using System.Windows.Forms; //…… […]

  • Skype API Basics – Part 1

    What is the Skype API? The Skype API is an easy way to create plugins that can dramatically change the way Skype functions. For example, we could make a program that reads messages out loud as we receive them instead of having to check for new messages. The Skype API is potentially very different for […]

  • Determine if Skype is Installed

    The easiest method of checking whether Skype is installed is actually to check for a Registry Key. We, of course, can’t check C:Program Files for a Skype Directory because the user could have installed elsewhere (or maybe if 64 bit the operating system did?) Skype’s API Document provides us with the following information: To check […]

  • Books I’ve Read

    Sometimes, when I have applied for full time employment in the past I have seen job ads or received responses from companies asking what books I’ve read. Nearly every time, I have heard this question I was so shocked because I didn’t ever keep track of what I had read or where I had gleamed […]

  • Sending Emails from C#.NET

    Emails are incredibly easy to send from .NET especially your typical plaintext email. We will be making use of the System.Net.Mail namespace along with an smtp server you should already have setup or you could use a free one like Gmail.

  • Read a Whole Textfile Into a String

    At work, I’ve been working on an auto html emailer.   I’ve been receiving files from our Latin American office that are completely in spanish and trying to sift through the HTML and recreate the email taking into account size and the fact that Outlook 2007 still doesn’t accept background images and most CSS. Anyway, one […]

  • How To Stop A .NET Form from Closing

    How to stop a form from closing in the .NET Framework