如果XML输出文件的路径尚不存在,如何获取C#? [英] How can I get C# to create the path of an XML output file if it doesn't already exist?

查看:129
本文介绍了如果XML输出文件的路径尚不存在,如何获取C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以让我的Visual Studio C#项目创建在XML输出位置中指定的文件夹(如果还不存在?),我将C#与Visual Studio 2012一起使用.部署时这个项目,它不会写XML文件,因为路径位置不存在,也不会创建它.

Is there a way that I can have my Visual Studio C# project create the folders specified in my XML output location (if they don''t already exist?) I''m using C# with Visual Studio 2012. When I deploy this project, it won''t write the XML files because the path location doesn''t exist and it won''t create it.

推荐答案

: http://msdn.microsoft.com /en-us/library/system.io.directory.createdirectory%28v=vs.110%29.aspx [
This is how: http://msdn.microsoft.com/en-us/library/system.io.directory.createdirectory%28v=vs.110%29.aspx[^].

Read carefully: you don''t really need to check up if the directory already exists. It will be created or not, but in both cases you will be able to create files in this directory, unless you have an exception related to invalid directory name, insufficient permissions, and the like.

—SA


这篇关于如果XML输出文件的路径尚不存在,如何获取C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆