我如何禁止在 TOpenDialog 中显示隐藏/系统文件?
我尝试编写一个程序来安全删除文件。但是,我在删除系统文件(回收站等)时遇到问题。现在我的问题是。在此对话框中隐藏文件(对用户)的方式。我将其他文件添加到列表视图,然后将它们重写为零。之后我删除了这个文件而不回收。
I tried to write a program for safe deleting files. However, I have a problem with deleting system files (recycle bin etc.). Now my question is. Which way to hidden files (from users) at this dialog. Other files I add to listview and then rewrite them zeroes. After that I delete this files without recycle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
保证做到这一点的唯一方法是编写您自己的打开文件对话框。但我建议您找到一种更好的方法来做到这一点,因为这被认为是非常糟糕的形式。
我刚刚想到,但是您可以做的(我并不是说这很容易或很好)是启动打开文件对话框,然后使用窗口句柄访问列表框,并根据您自己的启发手动从该列表中删除任何系统文件。它应该工作,但我不能保证这些项目将保持删除状态(即我认为Windows会经常自动刷新),所以你必须进行试验,YMMV。
底线:找到一种不同的方法来阻止用户选择它们。就像马特说的,也许只是传达一条信息,然后就这样了。如果做不到这一点,请编写自己的对话框(哎呀!)。
The only way guaranteed to do this is to write your own open file dialog. But I'd advise that you find a better way of doing this, since that's considered pretty bad form.
It just occurred to me, but what you could do (and I'm not saying it's easy or nice) is launch the open file dialog, then using the handle to the window gain access to the listbox, and manually remove any system files from that list per your own heuristics. It should work, but I can't guarantee that the items will remain removed (i.e. I think Windows will auto-refresh every so often), so you'll have to experiment and YMMV.
Bottom line: find a different way of preventing the user from selecting them. Like Mat says, perhaps just give a message and leave it at that. Failing that, write your own dialog (yuck!).