用字节数表示

解决方案 »

  1.   

    DWORD GetFileSize(
      HANDLE hFile,
      LPDWORD lpFileSizeHigh
    );
      

  2.   

    void filelength()
    {
    HANDLE hFile = INVALID_HANDLE_VALUE; hFile=CreateFile("E:\\2005年4月20日21时9分29秒.avi", GENERIC_READ, 0,
                                NULL, OPEN_EXISTING,
                                FILE_ATTRIBUTE_NORMAL, NULL);//改成你想知道的文件 int d=0;
    d=GetFileSize(hFile,0); CString cs;
    cs.Format("%d",d);
    MessageBox(cs);
    }
      

  3.   


    #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 ) );
       }
    }
    MSDN里的例子
      

  4.   

    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();