Ben Griswold on December 11th, 2008

I’m thinking it’s about time I start providing downloadable sample code along with my posts.  Rather than copying and pasting code snippets into your own solution, it might be nice to alternatively download a compressed sample project.  The Insert File Plugin for Windows Live Writer has been around for a while.  Here’s my attempt at [...]

Continue reading about Insert File Plugin

Ben Griswold on December 10th, 2008

Do you need a quick and cache wrapper class? Here’s a static class which I included in my more recent C# web application.  You’ll notice the class uses generics to allow for some, umm, generic functionality.  public static class CacheHelper { /// <summary> /// Insert value into the cache using /// appropriate name/value pairs /// [...]

Continue reading about C# Cache Helper Class

Ben Griswold on November 12th, 2008

Many of my C# methods include what is referred to as a guard clause.  It isn’t a complicated concept.  Simply the first few statements of a routine validates passed-in parameters and/or state of the object and immediately returns an error or gracefully exits to the function is constraints aren’t met.  If I’m not mistaken, this [...]

Continue reading about Guarding Against Multiple Empty Strings

Ben Griswold on July 25th, 2008

There’s a ton of information online about exporting a DataGrid or GridView to Excel, but most variations do not consider the GridView may reside within an UpdatePanel.  It goes without saying, but I was disappointed when I recently dusted off my “Export GridView to Excel” code snippet and encountered a number of exceptions.  So I [...]

Continue reading about Export GridView to Excel within an UpdatePanel

Ben Griswold on July 25th, 2008

This morning I needed to compose a very simple SQL routine and it took me around five compiles until I got the syntax right.  All I needed to do was transfer an active status from one entity (in my case a computer) to another.  I decided to implement this by updating the same table in [...]

Continue reading about TSQL – Self Update

Ben Griswold on July 3rd, 2008

I have collected a reasonably good size library of C# helper files over the years.  The EncryptionHelper below is one of many which I plan to share. using System; using System.Security.Cryptography; using System.Text; namespace Common { public static class EncryptionHelper { private const string cryptoKey = “cryptoKey”; // The Initialization Vector for the DES encryption [...]

Continue reading about C# Encryption / Decryption Helper Class

Ben Griswold on July 1st, 2008

In the same vein as my last post on how to programmatically update a service startup type, here’s how one might determine if a service is currently stopped in C#: using System.Management; /// <summary> /// This routine checks if the provided service is stopped. /// </summary> /// <param name=”serviceName”>Name of the service to be checked</param> [...]

Continue reading about Check Status of Windows Service

Ben Griswold on July 1st, 2008

For the past six years I’ve been focused on web applications.  My current project, however, has me splitting time between the web and the desktop.  Today, I needed to programmatically toggle the Startup Type of my service between Manual and Automatic based on business conditions.   Here’s how I did it: /// <summary> /// This routine [...]

Continue reading about Update Service Startup Type