名字空间 System.IO
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
namespace new_app
{
///
/// myxml 的摘要说明。
///
public class myxml : System.Web.UI.Page
{
private const string cdanme = "d:Mydir";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
my_CreateDirectory (cdanme);
}
public void my_CreateDirectory (string path)
{
try
{
// 检查目录是否存在
if (Directory.Exists(path))
{
Response.Write("目录已经存在.");
return;
}
// 创建目录
DirectoryInfo di = Directory.CreateDirectory(path);
Response.Write("目录应创建成功");
// 删除目录
//di.Delete();
//Console.WriteLine("目录已经删除.");
}
catch (Exception e)
{
Response.Write("出现异常");
}
finally {}