file size
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: file size

  1. #1
    Join Date
    Mar 2004
    Location
    pathankot,punjab, india
    Posts
    57

    file size

    how to get size of file
    plz explain with example

  2. #2
    Join Date
    Feb 2002
    Posts
    3,788

    Re: file size

    Originally posted by shosha
    how to get size of file
    plz explain with example
    MSDN:
    DWORD GetFileSize(
    HANDLE hFile, // handle of file to get size of
    LPDWORD lpFileSizeHigh
    // pointer to high-order word for file size
    );
    CFile::GetLength

  3. #3
    Join Date
    Oct 2003
    Location
    India
    Posts
    195
    For Opening the File:
    Code:
    HANDLE hFile; 
     
    hFile = CreateFile("MYFILE.TXT",           // create MYFILE.TXT 
                 GENERIC_WRITE,                // open for writing 
                 0,                            // do not share 
                 NULL,                         // no security 
                 CREATE_ALWAYS,                // overwrite existing 
                 FILE_ATTRIBUTE_NORMAL |       // normal file 
                 FILE_FLAG_OVERLAPPED,         // asynchronous I/O 
                 NULL);                        // no attr. template 
    
    if (hFile == INVALID_HANDLE_VALUE) 
    { 
        ErrorHandler("Could not open file.");  // process error 
    }
    For Getting the file size:
    Code:
    DWORD dwSize = GetFileSize(
      hFile,          //Handle to the file whose size is to be returned. 
      NULL          //Pointer to the variable where the high-order word of the file size is returned. 
    );
    if (dwSize != INVALID_FILE_SIZE) 
        <here display ur requested file's size ( dwSize ) >
    For Closing the File:
    CloseHandle(hFile);

    I think it gives better info. on ur problem!
    Last edited by KVR1; April 8th, 2004 at 01:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center