We are writing log files to File.applicationDirectory and want to clean out old log files. The question is how do you delete files out of that directory? When I try and delete old log files out of this directory it gives a security exception. Is there anyway around this?
I know you are not supposed to write to File.applicationDirectory, but we are writting are logs there anyways. So please don't just say don't do that!
I found the answer shortly after posting. I was lookin in FileTarget of how the write log file into the application directory and found t
var logFile:File = this._logDirectory.resolvePath(filename);
logFile = new File(logFile.nativePath); // Hack to get around SecurityError if log directory exists within the application directory
So you just specify the full native path and not a relative path from the application directory and you can do whatever you want. Interesting security model
Use the application storage directory: File.applicationStorageDirectory. This directory is specific to the application, where you can store data, such as log files. And you can add and remove files to this directory without restrictions.