Click here to Skip to main content
15,888,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRegarding CFile/CArchive usage Pin
H4u3223-Dec-07 16:53
H4u3223-Dec-07 16:53 
GeneralRe: Regarding CFile/CArchive usage Pin
CPallini23-Dec-07 21:25
mveCPallini23-Dec-07 21:25 
GeneralDLL_THREAD_ATTACH Pin
ForNow23-Dec-07 16:19
ForNow23-Dec-07 16:19 
GeneralRe: DLL_THREAD_ATTACH Pin
CPallini23-Dec-07 21:29
mveCPallini23-Dec-07 21:29 
GeneralRe: DLL_THREAD_ATTACH Pin
ForNow24-Dec-07 0:45
ForNow24-Dec-07 0:45 
GeneralCfile::typeText Pin
Larry Mills Sr23-Dec-07 6:55
Larry Mills Sr23-Dec-07 6:55 
GeneralRe: Cfile::typeText Pin
Mark Salsbery23-Dec-07 7:53
Mark Salsbery23-Dec-07 7:53 
GeneralRe: Cfile::typeText Pin
Larry Mills Sr23-Dec-07 10:08
Larry Mills Sr23-Dec-07 10:08 
I'm asking the wrong question I guess.Must you have a class "CStdioFile" in order to use CFile::typeText.
Here's my code:
TCHAR szBuffer[512];
UINT nActual = 0;
csFileName = "C:\\Shop Maintenance System\\REPORT FORMS\\TruckMaint.txt";

HANDLE hFile = CreateFile(_T(/*"CFile_File.dat"*/csFileName),
GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

if (hFile == INVALID_HANDLE_VALUE)
{
AfxMessageBox(_T("Couldn't create the file!"),MB_OK|MB_ICONEXCLAMATION);
}
else
{
// Attach a CFile object to the handle we have.
CFile m_fle(hFile);

//static const TCHAR sz[] = _T("I love CFile!");
m_fle.SetFilePath(csFileName);

// write string
//m_fle.Write(sz, sizeof(sz)); //Write( szBuffer, sizeof( szBuffer ) );
//m_fle.Write( szBuffer, sizeof( szBuffer ) );
m_fle.Seek( 0, CFile::begin );
nActual = m_fle.Read( szBuffer, sizeof( szBuffer ) );

// We can call Close() explicitly, but the destructor would have
// also closed the file for us. Note that there's no need to
// call the CloseHandle() on the handle returned by the API because
// MFC will close it for us.
m_fle.Close();
What the buffer contains is a bunch oontains is a bunch of "ffffffffffffffffffffffffffff...." so I think it's not giving me the text that I know is in the file. How do I get the text with the carrage returns, etc.?
A C++ programming language novice, but striving to learn
GeneralRe: Cfile::typeText Pin
Mark Salsbery23-Dec-07 10:37
Mark Salsbery23-Dec-07 10:37 
GeneralRe: Cfile::typeText Pin
Larry Mills Sr23-Dec-07 12:41
Larry Mills Sr23-Dec-07 12:41 
GeneralRe: Cfile::typeText Pin
David Crow23-Dec-07 14:01
David Crow23-Dec-07 14:01 
GeneralRe: Cfile::typeText Pin
Mark Salsbery24-Dec-07 6:24
Mark Salsbery24-Dec-07 6:24 
QuestionCreate skin for C++ Program Pin
BRIMID23-Dec-07 5:23
BRIMID23-Dec-07 5:23 
GeneralRe: Create skin for C++ Program Pin
Hamid_RT23-Dec-07 19:38
Hamid_RT23-Dec-07 19:38 
QuestionHow to determine the CListCtrl item height ? Pin
paper6723-Dec-07 2:18
paper6723-Dec-07 2:18 
AnswerRe: How to determine the CListCtrl item height ? Pin
Doc Lobster23-Dec-07 8:18
Doc Lobster23-Dec-07 8:18 
AnswerRe: How to determine the CListCtrl item height ? Pin
only coding23-Dec-07 21:22
only coding23-Dec-07 21:22 
GeneralBjarne's exception safe sample [modified] Pin
George_George23-Dec-07 1:05
George_George23-Dec-07 1:05 
GeneralRe: Bjarne's exception safe sample Pin
CPallini23-Dec-07 3:52
mveCPallini23-Dec-07 3:52 
GeneralRe: Bjarne's exception safe sample Pin
George_George23-Dec-07 16:42
George_George23-Dec-07 16:42 
GeneralNope Pin
CPallini23-Dec-07 20:50
mveCPallini23-Dec-07 20:50 
GeneralRe: Nope Pin
George_George23-Dec-07 21:04
George_George23-Dec-07 21:04 
GeneralRe: Nope Pin
CPallini23-Dec-07 21:18
mveCPallini23-Dec-07 21:18 
GeneralRe: Nope Pin
George_George23-Dec-07 21:25
George_George23-Dec-07 21:25 
GeneralRe: Nope Pin
CPallini23-Dec-07 21:41
mveCPallini23-Dec-07 21: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.