I like to use log files, each one created with the date of creation in its name, so that it doesn't grow to big.
Of course this needs cleaning up, so I automatically delete files older than one month.
On my windows x64 machine,
this used to work like expected, until now. Suddenly my log dir has read-only checked. And even though I, as a local admin user, am able to delete said directory, my wxWidgets app can't (access denied).
I create my log directory:
Code: Select all
wxFileName mfn_logDir = wxStandardPaths::Get().GetExecutablePath();
mfn_logDir.AppendDir("logs");
mfn_logDir.SetFullName("");
if (!wxDir::Exists(mfn_logDir.GetFullPath()))
{
mfn_logDir.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
}
Code: Select all
wxFileName fn_logfile = mfn_logDir;
wxString datetime = wxDateTime::Now().Format("%Y%m%d");
fn_logfile.AppendDir(datetime);
fn_logfile.SetName(wxDateTime::Now().Format("%Y%m%d-%H%M%S"));
fn_logfile.SetExt("log");
if (!fn_logfile.FileExists())
{
m_logFile.Create(fn_logfile.GetFullPath(), true, wxS_DEFAULT);
}
Code: Select all
if (!m_logFile.IsOpened())
{
m_logFile.Open(fn_logfile.GetFullPath(), wxFile::write_append);
}
unsigned long long len = strlen((const char*)sText.mb_str(wxConvUTF8));
m_logFile.Write((const char*)sText.mb_str(wxConvUTF8), len);
Code: Select all
if (!wxRemoveFile(rmDir + filename))
{
wxString sErr = "";
sErr = "Could not remove file \"" + rmDir + filename + "\"";
Log(sErr, false);
// -> Could not remove file "C:\wxWidgets-3.1.1\projects\synMedicoExporter\vc_mswu\Programm\exporterLog\20191209\20191209-154457.log"
}
[EDIT:] To clarify: I can write to that file. I just cant delete it anymore!
Any ideas what I or a windows update did here without my knowledge ?
Thanks.
Natu