Home > Article > Backend Development > asp.net creates a folder in the root directory of the website
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 } }