Yes. It works with any file. Though, it doesn't work with folders. Note that I suggested this because you asked for a simple way.
A more appropriate way to do this would be to use OS API functions -> http://msdn.microsoft.com/en-us/library/aa364418(v=vs.85).aspx
well, I'm totally confused when I read something at msdn, I'm just beginner and I really have no idea what that codes there means, so I don't wanna use them, and that thing with fstream works fine, so thanks! :)