As a chsarp developer, you must have learned the socket, and you know that the data transfor by network shoshould be rely on byte or XML.
There I will give the usually type converter in socket transfor
1: String byte [] (use to fransfor message in socket)
(1): String convert to byte []
String STR = "Wulong ";
Byte [] bytearray = system. Text. encoding. Default. getbytes (STR );
// You also cocould select your own encode Accoding to the requirement of Project
(2) byte [] convert to string
Byte [] bytearray; // you can get it by the socket, then convert to string
String STR = system. Text. encoding. Default. getstring (bytearray );
2: file byte [] (use to file transfor in socket)
(1): file to byte []
String filename = "";
Filestream = new filestream (filename, filemode. Open, fileaccess. Read );
Binaryreader = new binaryreader (filestream );
Binaryreader. basestream. Seek (0, seekorigin. Begin );
Byte [] bytes = binaryreader. readbytes (INT) binaryreader. basestream. Length );
(2): byte [] to filestream
Byte [] bytes;
Filestream = new filestream (filename, filemode. Open, fileaccess. Read );
Filestream. Write (bytes, 0, bytes. Length );
Then you coshould deal with the filestream
3: Image byte [] (use transfor image in socket)
(1): image to byte []
Image image = image. fromfile ("filepath ");
Memorystream MS = new memorystream ();
Image. Save (MS, system. Drawing. imaging. imageformat. PNG );
Byte [] byteimage = Ms. getbuffer ();
(2): byte [] to image
Byte [] byteimage;
Memorystream MS = new memorystream (byteimage );
Image imagegetbybytes = image. fromstream (MS );