Convert list of bytes to byte array

I'm getting this error: Value of type 'System.Collections.Generic.List(Of Byte)' cannot be converted to '1-dimensional array of Byte'."

Form this code: (below)

I understand the error, I just don't know how to implement a fix.

Dim bt As String = contents

        Dim test As New List(Of Byte)()
        Dim pointer As Integer = 0
        While pointer < bt.Length
            Dim move As Integer = 3
            Dim temp1 As String = bt.Substring(pointer, 3)
            If Convert.ToInt32(temp1) > 255 Then
                temp1 = bt.Substring(pointer, 2)
                move = 2
            End If
            pointer += move + 1
        End While
        My.Computer.FileSystem.WriteAllBytes("C:\MyDocuments\CustomerData", test, True)

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:

    My.Computer.FileSystem.WriteAllBytes("C:\MyDocuments\CustomerData", test, True)


    My.Computer.FileSystem.WriteAllBytes("C:\MyDocuments\CustomerData", test.ToArray, True)

The change was:

    test --> test.ToArray
APag96Author Commented:
I have tried that already and I get another error.  VB wants a byte array for the "WriteAllBytes"  code, but I created a list of bytes above.
Mike TomlinsonMiddle School Assistant TeacherCommented:
...and what error are you getting now?

"VB wants a byte array for the "WriteAllBytes"  code, but I created a list of bytes above."

Right...ToArray() creates a byte array from your List!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
APag96Author Commented:
ok... ok... Let me try it again...
APag96Author Commented:
It works. Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.