我想用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