Concerning your file permissions problem, I would probably put this kind of code in its own DLL (if you have a lot of it), make the operations public and then write integration tests that use the real file system. Writing unit tests probably isn't going to add much value for most cases.