Thanks for all your replies.

As I mentioned earlier, apart from checking and creating the directory in question, I need to make sure that the parent folder exists.(This needs to be done recursively until the drive is found and if not create the parent folder too.
The code I got from one of the previous posts does just that part.