Advertisement

08.14.2007 at 10:34AM PDT, ID: 22762160
[x]
Attachment Details

C# Binary Strings

Asked by vmadman in Microsoft Visual C#.Net, C# Programming Language, .Net Editors & IDEs

Tags: binary, string

Hi,
I am creating a web server capable of processing Multi-Part posts from incoming clients.

With multi-part (file posts) most of the stream is text, but the portion between the boundries is sometimes binary, if the user is trying to upload a binary file.

The problem im having is that the functionality offered by C# strings is, from what I can tell, required to parse the header, standard post data, etc .. but strings are not holding up so well when I try to store the incoming binary data to them.  I've tried just about every Decoding.GetString() combination known to man.

Primarily I use regex.split to find the boundries within the string so that I can determine which parts are binary and need binary processing... so I do not immediately see an alternative to converting the stream data out of it's natural byte[] array form (from BinaryReader.Read)... but it seems I lose characters when I convert it to a string using any method I've found so far.

Surely I am not the first person who has found a need to convert a byte array to a string for simple parsing?

Here is a quick example:
Content-Type: Multipart/FormData; boundry=----------7xxexample

------------7xxexample
Boundry Specific Headers etc etc
Content-Type="JFIF/JPEG"

ÿÿÿ0ÿ Adobe....  binary data, directly from the JPEG
------------7xxexample--

The biggest problem, again, is that I have to find those boundries ("----------7xxexample") within the stream, so I figure I need to convert the byte[] to a string.  But in doing so it destroys a lot of the binary JPEG data.

Any help is greatly appreciated,
-Luke

Start Free Trial
[+][-]08.14.2007 at 11:13AM PDT, ID: 19694251

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, C# Programming Language, .Net Editors & IDEs
Tags: binary, string
Sign Up Now!
Solution Provided By: DefNO
Participating Experts: 4
Solution Grade: A
 
 
[+][-]08.14.2007 at 04:57PM PDT, ID: 19696401

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.14.2007 at 08:51PM PDT, ID: 19697134

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.11.2007 at 01:44PM PDT, ID: 19872111

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.09.2007 at 05:07AM PDT, ID: 20040087

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10.19.2007 at 01:20PM PDT, ID: 20112014

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628