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

Thread: file size

Threaded View

  1. #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
  •  





Click Here to Expand Forum to Full Width

Featured