Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
this code opens a file and reads it, then paste the code in a edit box
C++
CStdioFile file;
   CFileException ex;

   if(file.Open(meow, CFile::modeRead ,&ex))
       {
       CString strString;
       while(file.ReadString(strString))
       {
           strFile += strString + _T("\r\n");
       }
       dad.SetWindowText(strFile);
       file.Close();
   }


the meow is a CSTRING path ...C:\\Users\\******\\Desktop\\1 - Copy (2)\\coo.txt


meow path is not working
why?
Posted
Updated 16-Jul-13 10:32am
v3
Comments
[no name] 16-Jul-13 16:58pm    
"why?", well that depends. What does "path is not working" mean? Does that path exist? Did you debug your code? Does that file exist? What does GetLastError tell you? Is this your real code or more code that has nothing to do with your actual problem like your last "question"?
Stefan_Lang 17-Jul-13 3:05am    
"Not working" or "why" are not valid questions. Neither are they proper titles for posting a question! It's like calling the garage, telling them your car isn't working, and then hanging up, hoping for them to fix your car, without seeing it, without knowing what the problem is, or how and when the problem occurs. What kind of response would you expect from your garage?

1 solution

Variable meow should be a TCHAR*

Have a look at the CString GetBuffer & ReleaseBuffer methods.
 
Share this answer
 
Comments
Stefan_Lang 17-Jul-13 3:01am    
Actually that shouldn't matter as it will be automatically converted via CString::operator LCTSTR() (see http://msdn.microsoft.com/en-us/library/aa300569%28v=vs.60%29.aspx )

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900