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.

Excizted commented: Theanks for repping. Also keep up with the friendly questions :) +1

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? :)

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 :)

commented: Thank You SO Much!! +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.