代码:
/**
*
* 文件的管理
*
*
* ****/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace IO目录管理
{
class Demo5
{
private string _Path1 = @"E:\TeacherLiuSutdy\Hight Level Teach\Test1.txt";
private string _Path2 = @"E:\TeacherLiuSutdy\Hight Level Teach\IO目录管理\Test1.txt";
/// <summary>
/// 创建文件
/// </summary>
public void Test1()
{
File.Create(_Path1);
}
/// <summary>
/// 文件删除
/// </summary>
public void Test2()
{
File.Delete(_Path1);
}
/// <summary>
/// 复制,不允许覆盖同名文件
/// </summary>
public void Test3()
{
File.Copy(_Path1,_Path2);
//File.Copy(_Path1, _Path2,true);//true允许覆盖则
}
/// <summary>
/// 剪切
/// </summary>
public void Test4()
{
File.Move(_Path1,_Path2);
}
/// <summary>
/// 判断文件是否存在
/// </summary>
public void Test5()
{
File.Exists(_Path1);
}
static void Main(string[] args)
{
Demo5 obj = new Demo5();
//obj.Test1();
//obj.Test2();
//obj.Test3();
obj.Test4();
Console.ReadKey();
}
}
}