在 Java 中显示 Windows 7 中的特殊隐藏文件/目录
从 Windows 7 开始,目录 windows/system32/drivers/etc 被特别隐藏。 Windows 7本身不显示它,但如果我手动打开它,它就在那里。
今天,我正在研究 Java JFace Eclipse 示例(http://www.ibm.com/developerworks/library/os-ecgui1/),并且想知道 java 也不显示 etc 目录。
那么使用 file.listFiles() 时如何获取所有目录/文件? 有什么想法吗?
Since Windows 7 the directory windows/system32/drivers/etc is specially hidden. Windows 7 itself doesn't show it, but it is there if I open it manually.
Today I was playing around with a Java JFace Eclipse example (http://www.ibm.com/developerworks/library/os-ecgui1/) and was wondering that java also doesn't show the etc directory.
So how can I get all directories/Files, when using file.listFiles() ?
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
File.listFiles()
方法应在结果中包含正常的“隐藏”文件。如果没有,则是因为操作系统级别发生了某些事情,向应用程序(而不仅仅是用户)隐藏了文件。我在
java.io.File
或 Java 7java.nio.*
扩展中找不到任何提到访问“特别隐藏”文件的内容。这可能是与权限相关的事情......如果是这种情况,解决方案是使用提升的权限执行 Java 应用程序。
但简单的解决方案是让您的应用程序远离 Windows 驱动程序目录树。
The
File.listFiles()
method should include normal "hidden" files in the result. If it does not, it is because of something going on at the operating system level to hide the files from the application (and not just the user).I could not find anything in either
java.io.File
or the Java 7java.nio.*
extensions that mention accessing "specially hidden" files.It could be a privilege related thing ... and if that's the case the solution is to execute the Java application with elevated privileges.
But the simple solution is for your application to keep its nose out of the Windows drivers directory tree.
正如我所写的,我尝试了一个 JFace 示例,它构建了一个基于 Java 的 Windows 资源管理器。
我同意你的观点,Java 应用程序通常不应在 Windows 驱动程序目录树中执行某些操作。
那里的“特别隐藏”文件可以通过 Total Commander 等其他程序看到,而无需以其他正常权限运行该程序。
我假设 Windows 有一些 API 函数来获取该信息。
我只是对基于 Java 的解决方案感兴趣,它可以向我显示磁盘上的所有内容......
As I wrote, I played around with an JFace Example, that builds up a Java based Windows Explorer.
I agree with you, that a Java application should normally not do something in the Windows driver directory tree.
The "specially hidden" files there, are visible with other programs like Total Commander without running this programs with other then normal rights.
I assume, that Windows has some API functions to get that information.
I'm just interested in a Java based solution that can show me everything, that's on my disk...