c# 文件操作的问题
using System;
using System.IO;
class text
{
public static void Main()
{
//指定详细的目录的路径
string path = @"e:\what";
string target = @"e:\name";
try
{
//判断目录是否存在
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
Directory.CreateDirectory(path + @"\mingzi");//创建的是目录
File.Create(path + @"\mm.txt");
}
if (Directory.Exists(target))
{
Directory.Delete(target);
}
//移动此目录
Directory.Move(path, target);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
}
}
}
注意红色的部分,我现在想在这个文件下创建一个mm.txt的文件,可是在程序运行的时候,却爆出了这么一个异常:
对路径“e:\what”的访问被拒绝,请问是为什么啊?
浙公网安备 33010602011771号