It may look redundant, but I can see a reason why someone decided to go that way.
The main difference is:
Directory.Exists()
returns justbool
Directory.CreateDirectory()
returnsDirectoryInfo
So even when the directory exists, there is additional work performed to get that DirectoryInfo
instance, which may not be necessary at all.
Another thing that come up is the fact, that you have to know that Directory.CreateDirectory
does not override the directory if it exists! With additional Directory.Exists
call even when someone doesn't know that he can really easily figure out what's going on with this piece of code.
And I don't think there is a best practice
here.