//**BROWSE DIALOG 1**//
//******************************************************//
char strFilter[] = "CPP Files (*.cpp)|*.cpp|All Files (*.*)|*.*||";
CFileDialog m_ldFile(TRUE, ".cpp", NULL, 0, strFilter);
if (m_ldFile.DoModal() == IDOK) //Start File dlg box
{
m_sFileName=m_ldFile.GetPathName(); //Get file name
FILE *fp=fopen(m_sFileName,"rb"); //Open file for reading
if( !fp )
{
DWORD dwError = GetLastError();
CString sError;
sError.Format("Open Error: %d, %d\n", errno, dwError);
AfxMessageBox(sError);
return;
}
// Get the file size
int nFileLong;
{
fseek(fp,0,SEEK_END); //Go to file end
nFileLong=ftell(fp); //Get length
fseek(fp,0,SEEK_SET); //Go to file start
}
char* sText = new char[nFileLong+1]; //reserve string space
int i=fread(sText,1,nFileLong,fp); //Read the characters
sText[i]=0; //Set string terminating null
fclose(fp); //Close file
// Make a copy
{
// FILE *file1 = fopen("C:\\Program Files\\C++ Clone Detector\\file1.txt","w+"); //Create txt file for saving editbox content
if( !file1 )
{
DWORD dwError = GetLastError();
CString sError;
sError.Format("Copy Error: %d, %d\n", errno, dwError);
AfxMessageBox(sError);
}
/*else
{
fwrite(sText,1,nFileLong,file1); //print the content of the editbox into the file
fclose(file1); //Close file2
}
*/
}
m_EDIT1=sText; //Put text in Edit box's variable
fwrite(sText,1,nFileLong,file1); //print the content of the editbox into the file
fclose(file1); //Close file2
delete [] sText;
UpdateData(FALSE); //Force data to go to Edit control
}