FileStream 和创建文件夹
只是一个简单的问题。我正在使用类似的东西,
FileStream fs = new FileStream(fileName, FileMode.Create);
我想知道是否有一个参数可以传递给它以强制它创建文件夹(如果它不存在)。目前,如果找不到文件夹,则会引发异常。
如果有更好的方法,那么使用 FileStream 我愿意接受想法。
Just a quick question. I'm using something like this
FileStream fs = new FileStream(fileName, FileMode.Create);
I was wondering whether there was a parameter I could pass to it to force it to create the folder if it doesn't exist. At the moment an exception is throw if folder isn't found.
If there is a better method then using FileStream
I'm open to ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Directory.CreateDirectory:
示例:
(Path.GetDirectoryName 返回目录文件名的一部分。)
Use Directory.CreateDirectory:
Example:
(Path.GetDirectoryName returns the directory part of the file name.)
像这样的东西:
Something like: