none
What is the difference between Visual C++ 2008 and Visual C++ 6 regarding a failed simple f.Open???? RRS feed

  • Question

  •  

    I have just converted an MFC program from Visual Studio 6 to Visual Studio 2008 (C++)
    This program works when compiled on V6 but not on 2008, they are both running on the same Vista 32 platform

    Ive tracked this failure down to this instruction, that opens a file window so you can select a file, but always returns FALSE when compiled under Visual C++ 2008 and works fine under V6

    Any suggestions much appreciated

    if( f.Open(dlg.GetFileName(), CFile::modeRead) == FALSE ) return;
    Above statement always returns false when compiled with Visual C++ 2008 after the file has been selected in dlg.GetFileName() window

    Wednesday, September 17, 2008 1:14 PM

All replies

  • I think it is likely that the problem is in dlg.GetFileName(). You can assign dlg.GetFileName to a variable and then check the variable to see if it is right.

    Thanks.

    ---------------------------

    Kevin Gao, MCSD MCDBA

    http://www.kevingao.net/

    Wednesday, September 17, 2008 1:36 PM
  • Hi Kevin

    Thanks for your help.  Ive just this moment tracked the problem down.  I think Visual C++ 2008 is running the MFC app in a user mode (non admin), whereas Visual C++ 6 isnt.

    The reason Ive come to believe this is that the error created was file not found (the file was in a folder off my route directory), and if I move the file I'm reading to the same directory as my project it all works. 

    Something to watch out for in the user experience that one, ive had several apps on vista irritatingly not see certain files, you think "but I can see them in explorer".  If you specifically run the app "as admin" suddenly the files appear.  Most disconcerting when you can actually see the directory, just not the file!

    Interestingly in this case dlg.GetFileName() shows you the file and returns the file name and path, followed by Open() returning a file not found if its not in the users allowed directories. Not sure how to get around that one for the user exp. Presumably those other apps that dont show the file use some other method, but not an idea situation in either case.

    Andy

    • Edited by andyevan Wednesday, September 17, 2008 2:00 PM
    Wednesday, September 17, 2008 1:52 PM