Click here to Skip to main content
15,923,374 members
Home / Discussions / C#
   

C#

 
Questionfile transfer Pin
giltendezm16-Feb-07 14:16
giltendezm16-Feb-07 14:16 
AnswerRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 16:47
Niiiissssshhhhhuuuuu16-Feb-07 16:47 
GeneralRe: file transfer Pin
giltendezm16-Feb-07 18:01
giltendezm16-Feb-07 18:01 
GeneralRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 19:18
Niiiissssshhhhhuuuuu16-Feb-07 19:18 
GeneralRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 19:27
Niiiissssshhhhhuuuuu16-Feb-07 19:27 
GeneralRe: file transfer Pin
giltendezm16-Feb-07 19:49
giltendezm16-Feb-07 19:49 
GeneralRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 19:56
Niiiissssshhhhhuuuuu16-Feb-07 19:56 
QuestionExcel ListObject to XmlDocument C# [modified] Pin
Raghutoo16-Feb-07 13:13
Raghutoo16-Feb-07 13:13 
QuestionDateTime Pin
Expert Coming16-Feb-07 12:37
Expert Coming16-Feb-07 12:37 
AnswerRe: DateTime Pin
Guffa16-Feb-07 13:58
Guffa16-Feb-07 13:58 
QuestionRemoving a " from a string Pin
sharpiesharpie16-Feb-07 12:16
sharpiesharpie16-Feb-07 12:16 
AnswerRe: Removing a " from a string Pin
Christian Graus16-Feb-07 12:18
protectorChristian Graus16-Feb-07 12:18 
GeneralRe: Removing a " from a string Pin
sharpiesharpie16-Feb-07 12:45
sharpiesharpie16-Feb-07 12:45 
GeneralRe: Removing a " from a string Pin
Christian Graus18-Feb-07 9:09
protectorChristian Graus18-Feb-07 9:09 
AnswerRe: Removing a " from a string Pin
Guffa16-Feb-07 14:01
Guffa16-Feb-07 14:01 
GeneralRe: Removing a " from a string Pin
sharpiesharpie16-Feb-07 15:46
sharpiesharpie16-Feb-07 15:46 
AnswerRe: Removing a " from a string Pin
Guffa17-Feb-07 14:58
Guffa17-Feb-07 14:58 
AnswerRe: Removing a " from a string Pin
Thomas Stockwell16-Feb-07 16:16
professionalThomas Stockwell16-Feb-07 16:16 
GeneralRe: Removing a " from a string Pin
sharpiesharpie17-Feb-07 1:34
sharpiesharpie17-Feb-07 1:34 
Questionhow to implement payflopro_recurringbilling through pfpro_dotnet_sdk_RC2_v1.1(verisign sdk) in c# Pin
shankhan bhandari16-Feb-07 11:33
shankhan bhandari16-Feb-07 11:33 
AnswerRe: how to implement payflopro_recurringbilling through pfpro_dotnet_sdk_RC2_v1.1(verisign sdk) in c# Pin
Wayne Phipps17-Feb-07 3:23
Wayne Phipps17-Feb-07 3:23 
QuestionProblem: vista will not sent a WM_ message [modified] Pin
michele_cv16-Feb-07 10:37
michele_cv16-Feb-07 10:37 
Questiongetting each byte of the pixel Pin
samreengr816-Feb-07 9:47
samreengr816-Feb-07 9:47 
AnswerRe: getting each byte of the pixel Pin
Christian Graus16-Feb-07 10:00
protectorChristian Graus16-Feb-07 10:00 
AnswerRe: getting each byte of the pixel Pin
Wayne Phipps17-Feb-07 4:29
Wayne Phipps17-Feb-07 4:29 
How about using serialisation? You could even use this to store practiaclly any object into a database.

Try this:
1) Create a new windows form app
2) Add to the form 2x picture boxes, one named source, the other dest
3) Add a new button named serialise
4) Set the background image of the picturebox named source to whatever you want (for testing, do this using the designer)
5) Add a handler to the buttons click event (this normally happens automatically if you double click the button in the designer)
6) Add using System.Runtime.Serialization.Formatters.Binary; declaration to your class
7) Paste the following code:
void SerialiseClick(object sender, EventArgs e)
{
    //serialise the background image of the source
    byte[] byteArray = Serialise( source.BackgroundImage );
    //deserialise the background image into the dest
    dest.BackgroundImage = (System.Drawing.Image)Deserialise(byteArray);
}

public static byte[] Serialise( object obj )
{
    //instanciate a new memory stream
    System.IO.MemoryStream ms = new System.IO.MemoryStream();
    //instanciate a new BinaryFormatter
    BinaryFormatter bf = new BinaryFormatter();
    //serialise the object into the memory stream
    bf.Serialize( ms, obj );
    //return the memory stream as a byte array
    return ms.ToArray();
}

public static object Deserialise( byte[] obj )
{
    //read the object into a memory stream
    System.IO.MemoryStream ms = new System.IO.MemoryStream( obj );
    //instanciate a binary formatter
    BinaryFormatter bf = new BinaryFormatter();
    //return the deserialised byte array as an object
    return bf.Deserialize(ms) ;
}


There is also Image.FromStream method which could be used instead and probably other ways of achieving a similar result.

Feel free to download the sample code I wrote from here: http://www.box.net/public/14kiat6na7

I love serialisation


Regards

Wayne Phipps
____________

Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.