帮我!我无法删除将其重命名的文件夹
问题描述:
这是我删除文件夹(不为空)的代码:
This is my code to delete a folder (not empty):
SHFILEOPSTRUCT fos = {};
fos.wFunc = FO_DELETE;
fos.pFrom = szTitlef;//path of folder ex: "D:\\tmp"
fos.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;
int t = SHFileOperation(&fos);
if ( t !=0)
{
//send error
}
但是结果是失败!我不知道我的代码的问题在哪里.
而且我想重命名文件夹,我不知道任何功能都可以使用.
感谢您的所有帮助!
but result is fail! i don''t know where ''s my code''s problem.
And i want to rename a folder, i don''t know any function can use.
Thanks for all help!
答
是的,我是第一次理解.但是我们szTitlef double NULL是否终止?例如,您可以通过附加"\ 0 \ 0"来使NULL终止字符串为double;
Yes I understood that the first time. But us szTitlef double NULL terminated? You can double NULL terminate a string by appending "\0\0", for example;
char buffer[] = "D:\\Temp";
int len = strlen(buffer);
char* folderName = new char[len+2];
strcpy(folderName, buffer);
folderName[len] = '\0';
folderName[len+1] = '\0';
您是否检查了GetLastError返回的信息?
-Saurabh
Did you checked what GetLastError returns?
-Saurabh
szTitlef double null是否终止?您还可以使用GetLastError找出SHFileOperation无法正常工作的原因.
-Saurabh
Is szTitlef double null terminated? You can also use GetLastError to find out why SHFileOperation is not working.
-Saurabh
当我调试时,szTitlef为"D:\\ tmp".但我无法删除它
When i debug, szTitlef is "D:\\tmp". but i can''t delete it