Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Okay, here is my code:

 

       Dim msNewStream As New MemoryStream
       Dim msstreamhass As New MemoryStream


       msNewStream.Write(msStream.ToArray, 0, msStream.Length - (hashsize * 8))
       Dim intP As Integer = msStream.Length - (hashsize * 8)
       intP = msStream.Length
       msStream.Position = 0

           msstreamhass.Write(msStream.ToArray, (msStream.Length - 159), msStream.Length)

 

The first part works fine "msNewStream.Write(msStream.ToArray, 0, msStream.Length - (hashsize * 8))"

 

The second one always throws an exception of:

Offset and Length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

 

Anyone have any ideas?

 

Thanks, Chester

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

Posted

As you say PlausiblyDamp they are not using intP between the assigments. But intP isn't actually being used at all in the code provided so I'm assuming that isn't whats causing your application to crash.

 

When you say the second part causes in error, are you refering to the line

msstreamhass.Write(msStream.ToArray, (msStream.Length - 159), msStream.Length)

 

For now I'm going to go ahead and assume this is the line throwing the error. There are 3 parameters being passed in a buffer, a start point and a length. For now lets ignore the buffer and look at the other 2 values. You are specifying the start point as 159 places before the end of the stream and then specifying the length as the full length of the stream. I'm assuming this is going to cause an error but I've never used a memorystream so I can't say for certain.

 

If the aim is to get only the last section of the stream I would suggest what you try this instead...

msstreamhass.Write(msStream.ToArray, (msStream.Length - 159), 159)

Anybody looking for a graduate programmer (Midlands, England)?
Posted

I have changed my method of working the problem and it is working fine now. I was using intP as merely a check when stepping through the code. I just wanted to see what values were there and was not actually using the variable for anything. I now have a new problem though that is dealing with this same application, but this one is for hashing so I will start a new thread on it. But thanks for the help :)

 

Chester

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...