Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to read HTML/Text file

Status
Not open for further replies.

BrianJH

Programmer
May 26, 2003
26
US
I am Developing a program to get HTML files off of the web and view their source code. So far I have been able to download the file, but I get an error that says "Access to Unnamed File Denied" when I try to read the file.

Here is my code for reading the file:

void CGetWebFileDlg::OnViewfile()
{

CFile myfile;
CFileException error;
CString filename;
char Source[1024];
//Done Initializing variables

//Get file name entered in dialog
m_strFileNameCtrl.GetWindowText(filename);

filename = "C:\\DOCS\\" + filename;
myfile.Open(filename,CFile::modeCreate | CFile::modeWrite,&error);

//HERE IS WHERE I GET THE ERROR
myfile.Read(Source,1024);
//Access to Unnamed File Denied!


//Send the source to the new dialog and initialize
htmldiag.m_Html = Source;
htmldiag.DoModal();
}

I Cleaned the code up a bit(removed error handling code)for easier viewing.
 
OOOPS! I forgot to ask if this is the best way to go about reading the HTML source off of this file or if I should try a different route...

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top