如何使用C#禁用特定文件夹的Windows预览窗格 [英] How to disable windows preview pane for particular folder using C#

查看:95
本文介绍了如何使用C#禁用特定文件夹的Windows预览窗格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用了hotfolder。启用hotfolder时,此文件夹将显示(共享)所有网络系统。网络PC用户将一些文件粘贴到此文件夹(hotfolder)中,它将进入我的应用程序。但是用户启用了Windows预览窗格到hotfolder,那时候预览将采用文件句柄,因为该文件没有到达我的应用程序。我想为我的hotfolder文件夹禁用Windows预览窗格。



我尝试过:



i试图关闭预览句柄,但我无法做到。

In my application, i used hotfolder. while enabling hotfolder this folder will shows(share) to all network systems. Network pc user paste some file in this folder(hotfolder), it will come to my application. but user enable windows preview pane to hotfolder, that time preview will take the file handle because of that file is not reached to my application. i want to disable windows preview pane for my hotfolder folder.

What I have tried:

i tried to close preview handle but i can not able to do.

推荐答案

你做不到。嗯,你可以,但用户可以重新打开它,你不能阻止它。



就像已在评论中说明的那样,你不能阻止用户打开文件并阅读它。地狱,即使只是复制文件打开它与独家锁。



您的代码必须被编写为容忍被锁定的文件,如果出现错误对话框,则显示错误对话框它是。您甚至可以让代码稍稍等待并重试打开文件。



这取决于你,但是防止用户在他们自己的机器上做某事永远不是解决问题的答案。
You can't. Well, you could but then the user can just turn it back on and you can't stop that.

Like was already stated in the comments, you can't stop a user from opening the file and reading it. Hell, even just copying the file opens it with an exclusive lock.

Your code has to be written to be tolerant of the file being locked, showing an error dialog if it is. You could even have the code just wait a bit and retry opening the file.

It's up to you, but preventing a user from doing something on their own machine is NEVER the answer to fixing a problem.


这篇关于如何使用C#禁用特定文件夹的Windows预览窗格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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