Dim ms As New MemoryStream(K - 1) ms.Write(MyData, 0, K)The documentation states that a MemoryStream created with an unsigned byte array can only be written to. Maybe creating it using just New MemoryStream() might work ? I'm afraid this is just guesswork on my part since I've never actually tried it either...