[英]Directory.Exists returns false when directory is present (works in a standalone console application but not in an ASP project)
As it is described in the title, ASP.NET project code can't find the directory, which exists and can be found by the console C# application.如标题所述,ASP.NET 项目代码找不到该目录,该目录存在,可以通过控制台 C# 应用程序找到。 (Disclaimer: I am totally new to .NET and C#). (免责声明:我对 .NET 和 C# 完全陌生)。
This displays "true" in the console application, but Directory.Exists
evaluates to false in the ASP.NET application.这在控制台应用程序中显示“真”,但在 ASP.NET 应用程序中, Directory.Exists
的计算结果为假。
string directoryPath =
"C:\\Users\\AndreasT\\ProjectDirectory\\ChildDirectory";
Console.WriteLine(Directory.Exists(directoryPath));
As I am new to .NET, I cannot give more detailed and accurate information at the moment, so I am looking for any suggestions of what could be wrong (permissions, project setup, etc.)由于我是 .NET 的新手,目前我无法提供更详细和准确的信息,因此我正在寻找任何可能出现问题的建议(权限、项目设置等)
Directory.Exists()
method returns false
if you dont have minimum read-only permission.如果您没有最低只读权限, Directory.Exists()
方法将返回false
。 It returns false
in the following conditions.它在以下情况下返回false
。
Reference: https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.exists?view=netcore-3.1#remarks参考: https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.exists?view=netcore-3.1#remarks
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.