The simplest way to check if your application has write access to a folder is to try to create a new file and check for error code. No error means you have write access. If creation succeeded, delete the file and check for error (You may have permission to create a file, write to it but not to delete it).
If you prefer to use the more complex way, see the answers to this question.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…