我想用File.ReadAllText和FileStream读取一个文本文件,但由于某种原因我每次都得到System.UnauthorizedAccessException。为什么访问路径被拒绝?
class consultas
{
public consultas()
{
}
private string Inativos = @"C:\Users\Mathias Cruz\Desktop\helloWorld\helloWorld\Consultas";
public string getInativos()
{
try
{
// string path = Directory.GetCurrentDirectory();
this.Inativos = File.ReadAllText(this.Inativos);
}
catch(Exception e)
{
throw e;
}
return this.Inativos;
}
}
为什么?我在该文件夹中有权限,那么为什么我会得到这个异常?
给这个帖子试一试:http://stackoverflow.com/questions/4877741/access-to-the-path-is-denied – pasotee