la clase CFile

11/08/2004 - 17:30 por Ronald Renteria Hinestroza | Informe spam
hola
estoy tratando de leer un acchivo plano con la clase CFILE pero no soy muy
bueno con MFC alguien puede ayudarme.

Gracias de antemano.

Preguntas similare

Leer las respuestas

#1 Angel J. Hernández
23/08/2004 - 02:40 | Informe spam
Espero te sirva... Saludos


Angel J. Hernández M.
MCSD

#include "stdafx.h"
#include <conio.h>
#include "Test.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object
CWinApp theApp;

using namespace std;


void GetFileContent(CFile* );

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) {
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed"));
nRetCode = 1;
} else {
CFileDialog* dlg = new CFileDialog(TRUE);
dlg->DoModal();

if (!dlg->GetFileName().IsEmpty()) {
CFile* file = new CFile();
if (file->Open(dlg->GetFileName(), CFile::OpenFlags::modeRead,
NULL)) {
GetFileContent(file);
file->Close();
}
}
}
return nRetCode;
}

void GetFileContent(CFile* file) {
int chartoread = 300;
char buffer[300];

while(((UINT) file->Read(buffer, chartoread)) > 0)
printf(buffer);
printf("Pulse una tecla para terminar...");
getch();
}


"Ronald Renteria Hinestroza" escribió en el mensaje
news:%
hola
estoy tratando de leer un acchivo plano con la clase CFILE pero no soy muy
bueno con MFC alguien puede ayudarme.

Gracias de antemano.


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida