Recently, in this project, you need to convert the client image to binary and save it to the database. Convert an image to binary: (1) convert the image to a [csharp] <span style = "white-space: pre "> </span> private byte [] reDyte (string strPath) {// read the file FileStream fsMyfile = new FileStream (strPath, FileMode. openOrCreate, FileAccess. readWrite); // create a binary data stream reader and associate it with the opened file BinaryReader brMyfile = new BinaryReader (fsMyfile); // locate the file pointer to the start of brMyfile. baseStream. seek (0, SeekOrigin. begin); byte [] bytes = brMyfile. readBytes (Conve Rt. toInt32 (fsMyfile. length. toString (); // close each of the above new objects brMyfile. close (); return bytes;} (2) Convert [csharp] <span style = "white-space: pre "> </span> private static byte [] Getbyte (Image img) {MemoryStream stream = new MemoryStream (); // img. save (stream, ImageFormat. jpeg); byte [] mydata = new byte [stream. length]; mydata = stream. toArray (); stream. close (); return mydata;} (3) convert binary to image [csharp] <sp An style = "white-space: pre"> </span> private System. drawing. image getImage (byte [] fileData) {System. IO. memoryStream MS = new System. IO. memoryStream (fileData); System. drawing. image img = System. drawing. image. fromStream (MS); return img;} (4) use image to display [csharp] <span style = "white-space: pre "> </span> private void ImgShow (WorkerInfo workerInfo) {string strPicture =" "; System. drawing. image imgPictureSho W = getImage (workerInfo. Photo); // define the file name strPicture = "Picture" + DateTime. Now. ToString ("yyMMddhhmmss"); imgPictureShow. Save (Server. MapPath ("~ /Pic/") + strPicture +" jpg ", System. drawing. imaging. imageFormat. jpeg); // display the file imgPicture. imageUrl = "pic/" + strPicture + ". jpg ";