How to create a directory using StreamWriter?

前端 未结 1 1729
死守一世寂寞
死守一世寂寞 2021-02-18 23:07

Is it possible to create a directory using StreamWriter?

相关标签:
1条回答
  • 2021-02-18 23:44

    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());
    
    0 讨论(0)
提交回复
热议问题