代码:
/**
*
* I0(文件)输入输出操作
*
* */
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;//输入输出流
using System.Reflection;
namespace IO目录管理
{
class Demo3
{
//指定路径
private string _Path1 = @"E:\TeacherLiuSutdy\Hight Level Teach\TestDIR";
/// <summary>
/// 创建目录
/// </summary>
public void Test1()
{
Directory.CreateDirectory(_Path1);
}
/// <summary>
/// 判断目录是否存在
/// </summary>
/// <returns></returns>
public bool Test2()
{
bool a =Directory.Exists(_Path1);
Console.WriteLine(a);
return a;
}
/// <summary>
/// 删除目录
/// </summary>
public void Test3()
{
Directory.Delete(_Path1);
}
/// <summary>
/// 获取当前工作目录
/// </summary>
public void Test4()
{
string result = Directory.GetCurrentDirectory();
Console.WriteLine(result);
}
/// <summary>
/// 获取当前程序集位置
/// </summary>
public void Test5()
{
string path = Assembly.GetExecutingAssembly().Location;
Console.WriteLine(path);
}
static void Main(string[] args)
{
Demo3 obj = new Demo3();
obj.Test1();
obj.Test2();
obj.Test3();
obj.Test2();
obj.Test4();
obj.Test5();
Console.ReadKey();
}
}
}