do you see anything wrong this this code. sSend is a class that encapsulates the winsock API.
Code:ifstream openfile((const char *)FileName.c_str(),ios::in | ios::binary); char tmpContent[10000] = {0}; int left = 0; if(openfile.is_open()) { //int length = openfile.tellg(); while(!openfile.eof()) { left = GetFileLen((char *)FileName.c_str()) - openfile.gcount(); if(left < 2048) { openfile.read(tmpContent, left); } else { openfile.read(tmpContent, 2048); } //openfile.read(tmpContent, left); sSend.SendData(tmpContent); } sSend.Close(); }Code:int GetFileLen(char *path) { ifstream TheFile((const char *)path, ios::in | ios::ate | ios::binary); return TheFile.tellg(); }




Reply With Quote