I was hoping it would be that simple : -) but when I tried:
Code:
DeleteFile("C:\\myfile.txt");
with my file name it still did not delete the file. I don't get any errors when compiling and executing the file simply does not get deleted. I checked my file locations and name and everything seems correct...
am I missing something, here is the code:
Code:
ifstream file;
char x;
CString buffer;
//Open file
file.open("C:\\mydbresults.txt", ios::in); //What ever your file is
//Check for file exist
if(!file)
{
CString facts = "File not found";
MessageBox(facts,NULL,MB_OK);
}
//Read data
while(file.get(x))
{
if(x=='\n')
{
m_List1.AddString(buffer);
//MessageBox(buffer,NULL,MB_OK); //Test buffer
buffer="";
}
else
buffer = buffer + x;
}
m_List1.AddString(buffer);
UpdateData(FALSE);
DeleteFile("C:\\mydbresults.txt");
Thanks-