Remove Directory function access denied
我正在使用下面的c代码从特定路径中删除临时文件。
C:\\Users\\falcon\\AppData\\Local\\Temp\\~GPG.TMP\\
在?GPG.TMP文件夹中存在一些文件时,它将首先删除,最后删除文件夹本身。在最后的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | void CFileOperation::DoDelete(CString sPathName) { CFileFind ff; CString sPath = sPathName; if (CheckPath(sPath) == PATH_IS_FILE) { if (!CanDelete(sPath)) { m_bAborted = true; return; } if (!DeleteFile(sPath)) throw new CFExeption(GetLastError()); return; } PreparePath(sPath); sPath +="*.*"; BOOL bRes = ff.FindFile(sPath); while(bRes) { bRes = ff.FindNextFile(); if (ff.IsDots()) continue; if (ff.IsDirectory()) { sPath = ff.GetFilePath(); DoDelete(sPath); } else DoDelete(ff.GetFilePath()); } ff.Close(); if (!RemoveDirectory(sPathName) && !m_bAborted) { throw new CFExeption(GetLastError()); } } |
根据MSDN:
而且,恕我直言,错误13是