1 //Read File contents2 3 CString filename1;4Filename1. Format (_t ("\\PHOTO\\%06ld%06ldCredPhoto.jpg"), Batchno, Voucherno);5 std::ifstream appfile (filename1. GetBuffer (), std::ios::binary);6 if(Appfile.good ())7 {8APPFILE.SEEKG (0, std::ios::end);9Lenfile = (int) Appfile.tellg ();Ten OneCountdownloadpacket =0; AAPPFILE.SEEKG (0, Std::ios::beg); - - if(lenfile% Pertranssize = =0) the { -Countpacket = lenfile/pertranssize; - } - Else + { -Countpacket = Lenfile/pertranssize +1; + } A for(inti = Countdownloadpacket +1; I < Countpacket +1; ++i) at { -memset (Szdata,0, Pertranssize +2); - -APPFILE.SEEKG ((I-1) *pertranssize, Std::ios::beg); -Appfile.read ((Char*) Szdata, pertranssize); -Lendata = (int) Appfile.gcount ();//the number of characters actually read in if(Lendata = =0) - { to Break; + } - the //szdata for this read data content, Lendata for the length. * $ }Panax Notoginseng}
C + + file stream