CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2013
    Posts
    9

    [RESOLVED] CFILE::GetStatus failed??Whats wrong?

    Hey guys ,

    I am trying to open a file from local Path by the follwing code

    CString csRegExtractFileRemote;
    CFileException ef;
    CFileStatus cfsStatus;
    CFile cfSAP;
    csRegExtractFileRemote = "c:\\SW\\RemoteFile\\sample.txt";

    if ( cfSAP.GetStatus(csRegExtractFileRemote, cfsStatus))
    {
    cout<<"YES\n"<<endl;
    // open up the Extract file and create an archive for it
    cout<<" Opening Extract file "<<endl;
    if( !cfSAP.Open( csRegExtractFileRemote, CFile::modeRead, &ef ) )
    {
    cout<<"FAILED\n"<<endl;
    printf("File %S could not be opened - %S",csRegExtractFileRemote,ef.m_cause);
    //cout<<"File '%s' could not be opened - %s", csRegExtractFileRemote, ef.m_cause);
    return FALSE;
    }
    cout<<"SUCCESS\n"<<endl;

    CArchive caSAP( &cfSAP, CArchive::load );
    CString csNewLine,
    csSyncStatus;
    int iTotalLines = 0;
    cout<<"Done till here"<<endl;
    }


    Compilation is success full ,but i am observing that some junk value i sthere in the path variable
    After Reaching If statment cursor went to final return statment ...


    I donknow whats wrong in this Code

    Can any one help me to resolve this

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: CFILE::GetStatus failed??Whats wrong?

    1) Please use code tags when posting code. Go Advanced, select the code and click '#'

    2) As you are trying to use the static version of GetStatus (without first opening the file), try

    Code:
    if ( CFile::GetStatus((LPCTSTR)csRegExtractFileRemote, cfsStatus))
    Note that GetStatus requires the file name as type LPCTSTR.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Jul 2013
    Posts
    9

    Re: CFILE::GetStatus failed??Whats wrong?

    Thanks for the reply ,that was a problem with file extension ..

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