用C函数获取文件的长度

2013-04-24 12:24:45 · 作者: · 浏览: 629

  #include <io.h>

  int GetFileSize(const char * pszFilePath)

  {

  FILE *fp = fopen(pszFilePath,  "rb");

  VERIFY(fp != NULL);

  const int nFile = _fileno(fp);

  const int nFileLength = _filelength(nFile);

  fclose(fp)

  return nFileLength;

  }