I'm new to using C++ but I thought I would give it a try. The goal is to delete all files and folders located in %userprofile%\Local Settings\Temp without deleting the folder called "Bluezone" located in the Temp folder. Any help would be appreciated.

Comments
Theanks for repping. Also keep up with the friendly questions :)

I'm new to using C++ but I thought I would give it a try. The goal is to delete all files and folders located in %userprofile%\Local Settings\Temp without deleting the folder called "Bluezone" located in the Temp folder. Any help would be appreciated.

Theres several ways you could do this :)
What comes to my head would be:

  1. List all folders and delete them individually if(name != "bluezone") ;)
  2. Take a backup of Bluezone, wipe it all out, and restore from the backup.

Theres several ways you could do this :)
What comes to my head would be:

  1. List all folders and delete them individually if(name != "bluezone") ;)
  2. Take a backup of Bluezone, wipe it all out, and restore from the backup.

Ok, I would like to try your first suggestion. Could you point me in the direction to list the folders and delete?

Do you need to delete only folders or files too? :)

Files too. Sorry I forgot to mention that.

Files too. Sorry I forgot to mention that.

Then with the windows header (windows.h) you can use FindFirstFile.

Example of usage:

WIN32_FIND_DATA findFileData;
HANDLE hFind;
hFind = FindFirstFile((LPCSTR)"C:\\Users\\Local Settings\\Temp\\*", &findFileData);
if(hFind != INVALID_HANDLE_VALUE)
{
string filename(findFileData.cFileName);
cout << filename;
} 

while(FindNextFile(hFind, &findFileData))
{
string filename(findFileData.cFileName);
cout << filename;
}

That should get you started, otherwise ask :)

Comments
Thank You SO Much!!
This article has been dead for over six months. Start a new discussion instead.