用字节数表示

解决方案 »

  1.   


    #include <time.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <stdio.h>void main( void )
    {
       struct _stat buf;
       int result;
       char buffer[] = "A line to output";   /* Get data associated with "stat.c": */
       result = _stat( "stat.c", &buf );   /* Check if statistics are valid: */
       if( result != 0 )
          perror( "Problem getting information" );
       else
       {
          /* Output some of the statistics: */
          printf( "File size     : %ld\n", buf.st_size );
          printf( "Drive         : %c:\n", buf.st_dev + 'A' );
          printf( "Time modified : %s", ctime( &buf.st_atime ) );
       }
    }
      

  2.   

    LONGLONG llTotalSize = 0;
    CFile fp = NULL;
    TCHAR tcFileName[MAX_PATH];
    GetModuleFileName(NULL,tcFileName,MAX_PATH);
    (_tcsrchr(tcFileName,'.'))[1] = 0;
    lstrcat(tcFileName,_T("pch"));

    if(fp.Open(tcFileName, CFile::modeRead|CFile::shareDenyNone|CFile::typeBinary,NULL) == 0)
    {
    fp.Close();
    return;
    } llTotalSize = fp.GetLength();
      

  3.   

    int length=0;
    FILE *pFile;
    pFile = fopen("路径", "rb");
    fseek(pFile,0,SEEK_END);
    length=ftell(pFile);
    fseek(pFile,0,SEEK_SET);
      

  4.   

    iFileLength = GetFileSize (hFile, NULL) ;