Blogger Information
Blog 1
fans 0
comment 0
visits 7072
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
c# 的判断文件夹是否存在/判断文件是否存在
穷_蹦跶
Original
7072 people have browsed it

sPath = Path.Combine(Environment.CurrentDirectory, duantoufolder);
//设置路径(将文件夹名合并到路径中)

//如果文件夹不存在
if (!Directory.Exists(sPath))
{
//创建文件夹 Directory.CreateDirectory(sPath);
}
//将文件的路径放进字符串变量
string textPath = Path.Combine(sPath, “test.txt”);
//如果文件不存再
if (!File.Exists(textPath))
{
//创建该文件
File.Create(textPath);
}

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!