I'm uploading an image, and i need to store it with the rest of the requested content by the server.

so right now im using

streamreader getimg = new streamreader(imagepath);
string image = getimg.readtoend();

string DataToBeUploaded = "requested content..." + image + "more requested content";

Everything is working, but the pixels in the picture get mixed up by the time it gets to the server (heres an example: http://img35.imageshack.us/img35/7844/taskmngr.png )

I was thinking i had to use some special encoding for images when saving it as a string?

9 Years
Discussion Span
Last Post by brando|away

Why are you attempting to store binary in a string? Use a byte[] array and what are the classes you're using.

Also please post these question to the ASP.NET forum in the future :)


Screen shots are irrelevant. What are you trying to do? Send and receive text & binary data in C#/ASP.NET?


yes im trying to send text with an image through a stream, and i cant figure out how to send it


Create an envelope or use two separate streams. IE you could create a class that holds a string and a byte[] array, serialize it, and send it across the pipe. You will probably want to base64Encode the binary data to serialize it.

Sending a string then binary data in a single stream is ill advised. It makes life hard for no reason.


Solved after 4 days of trial and error.

I just used a memorystream

thanks for trying though, i know i wasn't very descriptive.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.