如果任何C驱动器文件存在,File.Exist()将返回false。 [英] File.Exist() return false for any C drive file if that file exist their.

查看:92
本文介绍了如果任何C驱动器文件存在,File.Exist()将返回false。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

File.exist()对任何C盘文件都返回false,如果该文件存在且有效。

File.exist() return false for any C drive file if that file is exist their and valid too.

推荐答案

如果你的意思是File.Exists [ ^ ]而不是File.exit(我从未听说过)然后最可能的原因是你的应用程序运行的用户没有足够的访问权限来查看文件:

如果调用者具有所需权限且路径包含现有文件的名称,则为true;否则为false。如果path为null,无效路径或零长度字符串,则此方法也返回false。如果调用者没有有足够的权限来读取指定的文件,不抛出任何异常,无论路径是否存在,方法都返回false。 - - MSDN

如果您没有权限,则必须升级您的应用程序,或者在有权访问的用户下运行 - 取决于您的应用程序或服务的目的是做。
If you mean File.Exists[^] rather than File.exit (which I've never heard of) then the most likely reason is that the user under whom your application is runnign does not have sufficient access persmissions to look at the file:
"true if the caller has the required permissions and path contains the name of an existing file; otherwise, false. This method also returns false if path is null, an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of path." -- MSDN
If you don't have permission, you will have to either elevate your application, or run it under a user who does have access - depending on what your application or service is intended to be doing.


这篇关于如果任何C驱动器文件存在,File.Exist()将返回false。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆