Re: trouble converting CFileDialog to CFile to get size

From: Arnaud Debaene (adebaene_at_club-internet.fr)
Date: 10/20/04


Date: 20 Oct 2004 08:24:21 -0700


"Wayne..." <w.robson@oneteldsl.net> wrote in message news:<4173c494@212.67.96.135>...
> I am trying to get teh size of a file that will be opened using CFileDialog
> class, The trouble is it complains the moment I try the following
> m_FilePacked = GetFileSize(ldFile);

You don't give us enough information to be of any help :
- What is ldFile?
- In which context (function) are you writing this line of code?

GetFileSize takes an handle to a file handle (type HANDLE) opened
through CreateFile as it's first parameter. From your description, I
believe ldFile is either a CFileDialog or a CString (result from
CFileDialog::GetFileName). In both cases, it is totally unrelated to a
file handle.

Concerning your remark "To a learner it does seem somewhat strange
that GetFileSize() is not easily available from a CFileDialog". What
do you mean exactly? The aim of CFileDialog is to return the *name* of
a file (as a CString). This is totally unrelated to GetFileSize or to
the size of any file altogether.

Arnaud
MVP - VC



Relevant Pages

  • Re: trouble converting CFileDialog to CFile to get size
    ... > It's really not a member of CFileDialog. ... > GetFileSize is a Windows API in the global namespace (GetFileSize and ... > this file using the API CreateFile and, using the handle returned by this ...
    (microsoft.public.vc.language)
  • Re: trouble converting CFileDialog to CFile to get size
    ... It's really not a member of CFileDialog. ... GetFileSize is a Windows API in the global namespace (GetFileSize and ... this file using the API CreateFile and, using the handle returned by this ... returned when you first call CreateFile. ...
    (microsoft.public.vc.language)
  • Re: CFileDialog drives me insane. Handle Problem ?
    ... CString, so when the object is destroyed at the semicolon the pointer is left pointing to ... complex single lines) and you are using an LPSTR when you should be using a CString! ... ULONGLONG fSize = GetFileSizeInByte); ... CFileDialog, all works as expected. ...
    (microsoft.public.vc.mfc)
  • cfiledialog
    ... cfiledialog object. ... It launches fine, but I am unable to browse in the ... // where i call the derivated object of cfiledialog ... CString fileTypes; ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: CString; Stripping the filename from the string
    ... But how does a bunch of charaters look like white space to you??? ... AliR. ... >>> end of a CString after you filled the CString from a CFileDialog ...
    (microsoft.public.vc.mfc)