I am working on a project where my application monitors files/folders. The user can add/delete files/folders. Such files/folder can be remote shares too (NOT mapped drives) Whenever a new file/folder is added my application also computes and maintains some data regarding these files. Whenever files are deleted, my application needs to flush out the corresponding data. Unfortunately (for me) the flushing out is a non reversible operation.
Since I wanted the FS and my data to be in synch, I tried the following approach. 1) Check if my application has sufficient access permissions to delete the file/folder 2) If yes, flush out the data/delete file.
Since there is no File#canDelete() I used File#canWrite() (imagining both to effectively mean the same permissions). Surprisingly, file.canWrite() returns true but file.delete() returns false! Thus my data and the FS is out of synch.
Is there any way I can figure out if a particular file/folder can be deleted by my application?
Now I have set the permissions giving everyone full access. (initially there were no permissions and canWrite() was supposed to return false.) Now the files are getting deleted. But that was never the problem.