Posts

Showing posts from February, 2010

And now for something completely different

I use remote desktop almost every day. However it has the annoying habit of keeping idle connections open in a zombie state so when you try to logon to a server you get the dreaded max number of connections has been reached error. To bypass this you need to run the remote desktop app from the command line with some special switches. So to do this simply use this command from the command line prompt: mstsc /console /admin /v:<server>

Convert string to base64 string

A while back I came across the need to convert regular string text into a base64 string. .Net makes this fairly easy to do. I created a public static class and added two public static methods to encode/decode strings. Now they don't have to be static or public but I tend to make helper/utility classes that way. All of the classes being used are in the System and System.Text namespaces. /// <summary> /// Encodes the string to Base64. /// </summary> /// <param name="valueToEndcode">The value to endcode.</param> /// <returns>A base64 encoded string.</returns> public static string EncodeStringToBase64( string valueToEndcode ) { // encode the string into ascii byte array byte[] toEncodeAsBytes = ASCIIEncoding.ASCII.GetBytes( valueToEndcode ); // use the byte array to encode to a base64 string string returnValue = Convert.ToBase64String( toEncodeAsBytes ); // drop back the new encoded string value return returnVal