Convert Bitmap To Byte Array

If you need to convert a Bitmap to a Byte array, here is how you do it.   Public Shared Function ConvertToByteArray(ByVal value As Bitmap) As Byte()       Dim bitmapBytes As Byte()         Using stream As New System.IO.MemoryStream           value.Save(stream, value.RawFormat)         bitmapBytes … Continue reading Convert Bitmap To Byte Array

Convert An Array To A Delimited String

There are many times when I need to convert an array to a delimited string. Here is an easy way to do it using generics in .NET 2.0.   Public Shared Function ConvertArrayToString(Of arrayType As {IEnumerable})(ByVal array As arrayType(), ByVal separator As Char) As String         If Not IsValidArray(array) Then     … Continue reading Convert An Array To A Delimited String

Finding A Drives Serial Number

.NET still does not expose the drive serial number via the framework. For that you will need to use WMI. Here is the code. Shared Function GetDriveSerialNumber(ByVal drive As String) As String     Dim driveSerial As String = String.Empty       'No matter what is sent in, get just the drive letter   … Continue reading Finding A Drives Serial Number

Verify That An Array Is Valid

Here is some simple code to validate that an array is valid. Before trying to use an array, you should always validate it with this code first.   Public Shared Function IsValidArray(ByVal array As Array) As Boolean       Dim valid As Boolean = False         If array Is Nothing Then … Continue reading Verify That An Array Is Valid

Adding Blank Selection To A DropDownList Control – Part 2

When data binding to a DropDownList control in ASP.NET, there are in many cases when you want the first selection of the control to be blank or say something like "<please select value>". In part one of this tip (back in 2003), I wrote that you could just add an empty row to the DataSet. … Continue reading Adding Blank Selection To A DropDownList Control – Part 2

Threading in C#

Here is an excellent three part article on threading in C#:http://www.albahari.com/threading/