I spent pretty much all of last week trying to figure out windows file security, which was annoying. I got the setting permissions part using DACLs going pretty easily, then i tried to figure out how to turn off the bloody inheritance of permissions from higher up in the directory tree. I spent about two days trying to figure that out. I found sample code on MSDN and other places that claimed to do what i wanted but it seemed to do nothing when i tried it.
So today i figured screw that, i can override the inheritance by setting the right permissions, though that's kind of messy. I'll just do that and then work on something else less frustrating for awhile. So i move the bits of code that i know work to a new function and clean it up a little and test it out. Before i do so i notice that the file i'm testing has exactly the right permissions set, including the inheritance. I figured i must have been testing stuff manually on friday and set it that way, so i put it back to the starting values and test the code. It works. Perfectly. The permissions are set and the inheritance is turned off. I reset the permisions and try it again, it works again. I do this several times marveling in the wonder of code that starts working the way it's supposed to for no apparent reason.
Then i clean up the code a little bit. As far as i can tell, and verified with ctrl-z, all i did was change how the file name was being loaded and removed a function that was returning an error code anyway. (I was trying to set the security two different ways originally just to see which worked best.) And now it doesn't work at all! Not only does it not set the inheritance correctly, it doesn't even add the new permissions anymore! I tried undoing the changes and it still doesn't work! Like i said ctrl-z doesn't show any other changes that i'm unaware of, so what the hell is different now?!
I'm so friggin frustrated! Clearly the code hates me. Or the computer. Something sure does though!
Wow, banging your head against the computer really makes time seem to fly by. I suspect some form of blunt trauma-induced amnesia is responsible.