当前位置:网站首页>Creating files, recursively creating directories
Creating files, recursively creating directories
2022-06-24 22:18:00 【French red wine sweet】
problem :
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? I'm reading C# Some of the documents of IO Tutorial and try to write some files , But what if the path I give contains a directory ?
For example, I want to create the file called data/my_file except data folder doesn't exist. for example , I want to create a file named data/my_file The file of , but data Folder does not exist .
The line, Line ,
BinaryWriter outFile = new BinaryWriter(File.OpenWrite(path));where path 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. among path Is the above string , Crash and display a message that part of the path does not exist , It means C# They were not created as required .
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. I hope C# Deal with all the messy directory creation and check me , Instead of having to resolve the path and create all the necessary directories .Is this possible? Is that 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). otherwise , Is there a piece of code that can be copied into my project , It can handle anything that I might overlook ( Because I know very little about document management ).
Solution :
Reference resources : https://stackoom.com/en/question/juQL边栏推荐
- Huada 04A operating mode / low power consumption mode
- Machine learning: linear regression
- “阿里健康”们的逻辑早就变了
- 学习笔记23--多传感器信息融合基础理论(上)
- Learning notes 23-- basic theory of multi-sensor information fusion (Part I)
- Filtered data analysis
- socket(2)
- [notes of Wu Enda] multivariable linear regression
- Stl+ tree
- Detailed installation and use of performance test tool wrk
猜你喜欢

Common voting governance in Dao

Multithreaded finalization

A pit in try with resources

Reduce the pip to the specified version (upgrade the PIP through pycharm, and then reduce it to the original version)

Huada 04A operating mode / low power consumption mode

You are using pip version 21.1.2; however, version 22.1.2 is available

一个女孩子居然做了十年硬件。。。

刷题笔记(十八)--二叉树:公共祖先问题

Notes on writing questions (18) -- binary tree: common ancestor problem

Detailed installation and use of performance test tool wrk
随机推荐
Rotate the square array of two-dimensional array clockwise by 90 °
[notes of Wu Enda] multivariable linear regression
Ansible basic configuration
Docker 安装 MySQL 8.0,详细步骤
How to grab the mobile phone bag for analysis? Fiddler artifact may help you!
Detailed installation and use of performance test tool wrk
Docker 安装 Redis-5.0.12,详细步骤
Common voting governance in Dao
Reduce the pip to the specified version (upgrade the PIP through CMP and reduce it to the original version)
Yida technology signed a contract with seven wolves to help the digital transformation of "Chinese men's wear leader"
Flutter: Unsupported value: false/true
DAO 中常见的投票治理方式
Redis+caffeine two-level cache enables smooth access speed
解决dataframe报错ValueError: Cannot take a larger sample than population when ‘replace=False‘
磁盘的结构
NIO 零拷贝
Servlet details
零代码即可将数据可视化应用到企业管理中
Description of software version selection of kt6368a Bluetooth dual-mode transparent chip
Find the maximum value in each tree row [extension of one of the hierarchical traversals]
