Home  >  Article  >  Backend Development  >  asp.net creates a folder in the root directory of the website

asp.net creates a folder in the root directory of the website

巴扎黑
巴扎黑Original
2016-12-19 15:53:591936browse

Suppose you want to create a folder hovertree in the root directory of the asp.net website, the C# code is as follows:

string m_keleyiFolderName = Server.MapPath("/hovertree");
if (Directory.Exists(m_keleyiFolderName))
{
//文件夹已经存在
return;
}
else
{
try
{
Directory.CreateDirectory(m_keleyiFolderName);
//创建成功
}
catch (Exception ex)
{
//创建失败 ,原因: ex.Message
}
}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn