怎么用ASP在服务器上建立一个文件夹 C#语言

来源:百度知道 编辑:UC知道 时间:2024/06/22 20:17:33
谢谢大虾们了~~~

asp:
set fso=createobject("scripting.filesystemobject")
fso.createfolder(server.mappath("文件夹相对路径"))
set fso=nothing

asp.net c#
using System.IO; //这句加在cs头部

public void CreateFolder(string path)
{
//判断是否有该文件夹
if (Directory.Exists(path))
{
//删除该文件夹。
Directory.Delete(path,true);
}
//创建文件夹
Directory.CreateDirectory(path);
}

调用:this.CreateFolder(Server.MapPath("您的文件夹路径"));

System.IO.Directory.CreateDirectory(@"d:\directory");
当然"d:\directory"也可以用System.IO.Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath("directory"));