Jump to content
  • Advertisement
Sign in to follow this  
discodowney

Deleting a directory using SHFileOperation

This topic is 2498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[color=#000000][font=Arial,]I have a function that deletes folders. (does other stuff, hence the switch, but i took them out to save space)[/font]


void SHFileOperationFunc(string item1, string item2, int operation)
{
string files;
SHFILEOPSTRUCT sf;
memset(&sf,0,sizeof(sf));
sf.hwnd = 0;
sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI;

switch(operation)
{
case FO_DELETE:
sf.wFunc = FO_DELETE;
item1.append(1, '\0');
sf.pFrom = item1.c_str();
break;

}

int opOkay = SHFileOperation(&sf);
if(opOkay != 0)
{
//FAIL
}

}


[color=#000000][font=Arial,]It works for folders where there are one (even a 50 MB) or no files. But when a folder has more than one file it wont delete the folder. When i try to access the folder through windows explorer after the function is called it says Access is denied. The SHFileOperation call is returning 0 so it seems to think it is working. Anyone know what might be going on?[/font]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!