OK. I've looked into this and finally figured out exactly what is going on.
The content that is loaded from the HttpPostedFile via the InputStream
property is always NULL (Nothing, Zero) terminated. I've searched and
searched and searched to find documentation on this but cannot find it
anywhere. However, I can't find my keys most days either so that's not
saying much.
So, the long and the short of it is that I've modified my stream reader to
strip off the last character *AFTER* this is said and done. AFTER is very
important here. Remember what I said above, "the content ... is *always*
NULL terminated." So if you just read in ContentLength() -1 you still get
the terminating NULL byte. You have to strip it off after you've decoded the
stream.
In my case it looks like this:
Dim Buffer() As Byte
Dim nBuffSize As Integer = postedFile.ContentLength()
Buffer = New Byte(nBuffSize) {}
postedFile.InputStream.Read(Buffer, 0, nBuffSize)
Dim theEncoding As Encoding = Encoding.GetEncoding("windows-1252")
strReturn = theEncoding.GetString(Buffer)
' The HttpPostedFile.InputStream is always terminated with a zero char
' so just strip it off during input
strReturn = strReturn.Substring(0, strReturn.Length - 1)
So, that's the best I could do in figuring out how to solve this. If someone
else has the "proper" way of doing it I'd love to hear about.
--
Sincerely,
Drew Berkemeyer
Software Architect
http://www.berkemeyer.com/
"Drew Berkemeyer" <sp**@menow.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
This is *excellent* feedback. Thank you so much for your help.
I will install the SOAP toolkit.
Yesterday I installed Ethereal (http://www.ethreal.com/) and captured the
HTTP stream. I discovered in doing this that the <input type=file> content
apears to have a trailing zero that apparantlly is not showing up in the
String.Compare call and is not present in the text that is posted into the
Textbox control. Since I do not have conclusive evidence as to exactly
what is going on I won't post the results yet.
Instead, I'll install the SOAP toolkit and do just a little more research
and post my results here.
Thank you again for taking the time to help me out. It is really
appreciated.
Sincerely,
Drew Berkemeyer
http://www.berkemeyer.com/
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:iW**************@cpmsftngxa10.phx.gbl... Hi Drew,
From your description, the same webservice call with the two string
content
( which are proved as idential via String.Compare) will result different
behavior. Currently, I think we can do the following tests:
1. Try using the String.Equals( ) instead of the String.Compare (which
will
make use of the current culture info when do the comparation) to make
sure
that the two string are exactly idential. ( or save to the txt file via
the
same encoding to compare the file content).
2. Make sure whether the error occurs before the webservice request be
processed at the serverside or after the serverside processing( when the
client retrieve the response content). You may create another simple
webservice( or webmethod which take a string parameter ) and do the same
test on the given file or text.
3. If possible, you can also try using the MS SOAP tookit3 's Trace
Utility to capture the RAW SOAP message to see whether the two request
have any difference. The soap Toolkit3 can be downloaded at the following
address:
http://www.microsoft.com/downloads/d...0DD-CEEC-4088-
9753-86F052EC8450&displaylang=en
Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)