1 // The image's "read" Operation 2 // ① parameter is the image path: returned byte [] type: 3 // The parameter is the image Path 4 Public byte [] getpicturedata (string ImagePath) {5 filestream FS = new filestream (ImagePath, filemode. open); 6 byte [] bytedata = new byte [FS. length]; 7 FS. read (bytedata, 0, bytedata. length); 8 FS. close (); 9 return bytedata (); 10} 11 // The parameter type is an image object, and the byte [] Type 12 // converts the image to the stream data, save as byte [] & nbsp; 13 public byte [] photoimageinsert (system. drawing. image imgphoto) 14 {15 memorystream mstream = new memorystream (); 16 imgphoto. save (mstream, system. drawing. imaging. imageformat. BMP); 17 byte [] bydata = new byte [mstream. length]; 18 mstream. position = 0; 19 mstream. read (bydata, 0, bydata. length); mstream. close (); 20 return bydata; 21} 22 // The "write" operation for the image 23 // ① parameter is of the byte [] type, and the return value is the image object 24 public system. drawing. image returnphoto (byte [] streambyte) 25 {26 system. io. memorystream MS = new system. io. memorystream (streambyte); 27 system. drawing. image IMG = system. drawing. image. fromstream (MS); 28 return IMG; 29} 30 // The parameter is of the byte [] type and has no return value (Asp. net output image) 31 public void writephoto (byte [] streambyte) 32 {33 // response. the default value of contenttype is "text/html" 34 response. contenttype = "image/GIF"; 35 // The image output types include: image/GIF image/JPEG 36 response. binarywrite (streambyte); 37}