Is it possible to create a directory using StreamWriter?
No. You can't actually create a directory using a StreamWriter. Use Directory.CreateDirectory instead.
If you're trying to read the directory name out of a file stream and then create a file based on that text, you'll need something like this:
FileStream fs; // this is the filestream from somewhere. make sure to dispose it
using (StreamReader r = new StreamReader(fs))
Directory.CreateDirectory(r.ReadToEnd());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With