Remove the file in use
-
Hello I have a little big problem that drive me crazy for 3 hours. I have a function that browse the content of a folder (with subfolders). After that operation is done I want to delete the folder. The function is recursive. All the files in the route folder are deleted ok. But I cannot delete the subFolders and their content. I use this code for retrieve information about files and folders:
WIN32_FIND_DATA FindFileData;
HANDLE hFind=INVALID_HANDLE_VALUE;
hFind= FindFirstFile(aux,&FindFileData);FindNextFile(hFind, &FindFileData);
I guess that it is us How can I remove the file/folder in use tag? I tried with
delete &FindFileData
it doesn't work. There must be a way out there ... I tried to delete the folder without browse it first and it works fine. The weird thing is that I can delete the files that are in the root.
-
Hello I have a little big problem that drive me crazy for 3 hours. I have a function that browse the content of a folder (with subfolders). After that operation is done I want to delete the folder. The function is recursive. All the files in the route folder are deleted ok. But I cannot delete the subFolders and their content. I use this code for retrieve information about files and folders:
WIN32_FIND_DATA FindFileData;
HANDLE hFind=INVALID_HANDLE_VALUE;
hFind= FindFirstFile(aux,&FindFileData);FindNextFile(hFind, &FindFileData);
I guess that it is us How can I remove the file/folder in use tag? I tried with
delete &FindFileData
it doesn't work. There must be a way out there ... I tried to delete the folder without browse it first and it works fine. The weird thing is that I can delete the files that are in the root.
Did you use
FindClose(hFind)
? -
Hello I have a little big problem that drive me crazy for 3 hours. I have a function that browse the content of a folder (with subfolders). After that operation is done I want to delete the folder. The function is recursive. All the files in the route folder are deleted ok. But I cannot delete the subFolders and their content. I use this code for retrieve information about files and folders:
WIN32_FIND_DATA FindFileData;
HANDLE hFind=INVALID_HANDLE_VALUE;
hFind= FindFirstFile(aux,&FindFileData);FindNextFile(hFind, &FindFileData);
I guess that it is us How can I remove the file/folder in use tag? I tried with
delete &FindFileData
it doesn't work. There must be a way out there ... I tried to delete the folder without browse it first and it works fine. The weird thing is that I can delete the files that are in the root.
Why don't you use
DeleteFile(FindFileData.cFileName);
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Hello I have a little big problem that drive me crazy for 3 hours. I have a function that browse the content of a folder (with subfolders). After that operation is done I want to delete the folder. The function is recursive. All the files in the route folder are deleted ok. But I cannot delete the subFolders and their content. I use this code for retrieve information about files and folders:
WIN32_FIND_DATA FindFileData;
HANDLE hFind=INVALID_HANDLE_VALUE;
hFind= FindFirstFile(aux,&FindFileData);FindNextFile(hFind, &FindFileData);
I guess that it is us How can I remove the file/folder in use tag? I tried with
delete &FindFileData
it doesn't work. There must be a way out there ... I tried to delete the folder without browse it first and it works fine. The weird thing is that I can delete the files that are in the root.
Can you use of _rmdir or SHFileOperation without this code?
-
Can you use of _rmdir or SHFileOperation without this code?
-
And what result?
-
And what result?
I used this to erased a folder and it works
SHFILEOPSTRUCT op;
op.pFrom = szStoreFolder;
//op.pTo = _T(""); //will be ignored
op.wFunc = FO_DELETE;
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
op.fAnyOperationsAborted = false;
op.hNameMappings = NULL;
SHFileOperation(&op);only if you do not have the files in that folder in used... if you have that you should FindClose(handleFile) if you used previous a function that searched for file in that folder