Directory.CreateDirectory() for a file path while ignoring the filename
I have a file with full path
/path/to/some/very/long/file.txt. I would like to be able to use Directory.CreateDirectory(path) to create all folders and subfolders on the way to that file, but in practice, it ends up creating a file.txt folder at the end. Is there a more elegant solution to this other than splitting my path string on / and reforming it minus the last piece?