Click here to Skip to main content
15,897,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProblem with IE7 Pin
H4u323-May-08 3:49
H4u323-May-08 3:49 
AnswerRe: Problem with IE7 Pin
BadJerry11-Sep-09 6:46
BadJerry11-Sep-09 6:46 
QuestionNeed Help with CStdioFile Pin
Larry Mills Sr3-May-08 2:48
Larry Mills Sr3-May-08 2:48 
AnswerRe: Need Help with CStdioFile Pin
Mark Salsbery3-May-08 7:55
Mark Salsbery3-May-08 7:55 
GeneralRe: Need Help with CStdioFile [modified] Pin
Larry Mills Sr4-May-08 3:28
Larry Mills Sr4-May-08 3:28 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery4-May-08 6:17
Mark Salsbery4-May-08 6:17 
GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr4-May-08 9:10
Larry Mills Sr4-May-08 9:10 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery4-May-08 11:04
Mark Salsbery4-May-08 11:04 
Larry Mills Sr wrote:

pszFileName is a TCHAR and m_csFileName is a CString


Again, there should be no difference here unless you initialize/set
the CString with a different string than your TCHAR pointer points to.

You're getting hung up on the string type when it's probably either the
pathname or the Open() flags that are bad.

What about starting simple. Create/open a file you know is going to succeed.
Use the CFile::Open() method flags properly, get the file to create and/or open
and then worry about writing to it.

Try this (works great on this end)....note that I've used one access permission (CFile::modeReadWrite)
and one share option (CFile::shareDenyWrite), as the docs state I should:
CString m_csFileName("e:\\testastdiofile.txt"); <code>//<--set this to an appropriate pathname!!</code>
CStdioFile myFile;
CFileException ex;
if(!myFile.Open(m_csFileName, CFile::modeNoTruncate | CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyWrite | CFile::typeText, &ex))
{
    TCHAR szError[1024];
    ex.GetErrorMessage(szError, 1024);
    AfxMessageBox(szError, MB_OK, 0);
    return;
}
myFile.SeekToEnd();  <code>//<-- do this only if you want to append to an existing file!</code>
myFile.WriteString(_T("A string\r\n"));
myFile.Close();


Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr5-May-08 2:48
Larry Mills Sr5-May-08 2:48 
QuestionRe: Need Help with CStdioFile Pin
David Crow5-May-08 3:00
David Crow5-May-08 3:00 
AnswerRe: Need Help with CStdioFile Pin
Larry Mills Sr5-May-08 4:57
Larry Mills Sr5-May-08 4:57 
GeneralRe: Need Help with CStdioFile Pin
David Crow5-May-08 5:25
David Crow5-May-08 5:25 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery5-May-08 5:55
Mark Salsbery5-May-08 5:55 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery5-May-08 6:05
Mark Salsbery5-May-08 6:05 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery5-May-08 4:59
Mark Salsbery5-May-08 4:59 
GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr5-May-08 6:42
Larry Mills Sr5-May-08 6:42 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery5-May-08 6:47
Mark Salsbery5-May-08 6:47 
GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr5-May-08 7:11
Larry Mills Sr5-May-08 7:11 
GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr6-May-08 5:42
Larry Mills Sr6-May-08 5:42 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery7-May-08 6:33
Mark Salsbery7-May-08 6:33 
GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr8-May-08 8:03
Larry Mills Sr8-May-08 8:03 
GeneralRe: Need Help with CStdioFile Pin
Larry Mills Sr11-May-08 16:22
Larry Mills Sr11-May-08 16:22 
GeneralRe: Need Help with CStdioFile Pin
Mark Salsbery11-May-08 16:50
Mark Salsbery11-May-08 16:50 
QuestionHow can use Keyboard interaction to application? Pin
Le@rner3-May-08 2:03
Le@rner3-May-08 2:03 
AnswerRe: How can use Keyboard interaction to application? Pin
Nelek5-May-08 1:41
protectorNelek5-May-08 1:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.