'Unable to delete file with _wremove API (permission issue)
I'm unable to delete a temporary file from my C++ application, it's failing with "permission denied" error. Here's the code snippet,
void DeleteTempFile(const std::wstring& path) {
wchar_t* wc = const_cast<wchar_t*>( path.c_str() );
if( _wremove( wc ) != 0 )
Log(fatal, std::string("Error: ") + std::strerror(errno) + std::string(" while deleting file: ") + std::string(path.begin(),path.end()));
else
Log(fatal, std::string("Successfully deleted file: ") + std::string(path.begin(),path.end()));
}
And this is the log I'm getting when I execute this code,
Error: Permission denied while deleting file: C:/Windows/SERVIC~1/LOCALS~1/AppData/Local/Temp/abcD12E.pdf
Can somebody please help me in resolving this permission issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|