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

Thread: FILE vs CFile

  1. #1
    Join Date
    Sep 2003
    Location
    M...N
    Posts
    220

    FILE vs CFile

    Anyway to do conversion between FILE and CFile object?

  2. #2
    Join Date
    Apr 2006
    Posts
    79

    Re: FILE vs CFile

    CFile is a MFC class meanwhile FILE is a data type of ANSI C.
    My English is not good. So you maynot understand what I say!

  3. #3
    Join Date
    Sep 2003
    Location
    M...N
    Posts
    220

    Re: FILE vs CFile

    Yes. and any way to convert an CFile object to FILE stream?
    (Or let a FILE stream pointer point to CFile object and get the correct result?)

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: FILE vs CFile

    FILE* to CFile
    Code:
    FILE*  f      = fopen(path, szMode);
    int    handle = f->_file;
    HANDLE hFile  = (HANDLE) _get_osfhandle(handle);
    CFile cf(hFile);
    CFile to FILE*
    Code:
    CFile cf;
    cf.Open(...);
    HANDLE hFile  = cf;
    int    handle = _open_osfhandle((LONG)hFile, _mode);
    FILE*  f      = fdopen(handle, szMode);
    Last edited by Igor Vartanov; December 26th, 2007 at 07:39 AM.
    Best regards,
    Igor

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