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.
Also, is this the best method for performing this action? If not, could someone let me know a better way?
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.
Also, is this the best method for performing this action? If not, could someone let me know a better way?