creating files, recursively creating directories
<p>I was reading some file IO tutorials for C# and have managed to write out some files, but what if the path I'm given contains directories?</p>

<p>For example, I want to create the file called <code>data/my_file</code> except <code>data</code> folder doesn't exist. </p>

<p>The line,</p>

<pre><code>BinaryWriter outFile = new BinaryWriter(File.OpenWrite(path));
</code></pre>

<p>where <code>path</code> is the above string, crashes with the message that part of the path doesn't exist, which means C# isn't creating them as required.</p>

<p>I would like C# to handle all of the messy directory creation and checking for me instead of me having to parse the path and create all of the necessary directories. Is this possible? Otherwise, is there a snippet of code that I can just copy over into my project which will handle anything I might be overlooking (since I don't know much about file management).</p>
