如何在 VBA (MSAccess) 中检查文件加密
我正在构建一种表单,根据数据库中的数据将文件从一个位置移动到另一个位置,只要源文件未加密(Windows 资源管理器中的绿色文件名)并且目标文件不存在,它就可以工作。
所以我试图创建以下内容:
Public Function isEncrypted(file As String) As Boolean
Dim info As System.IO.FileInfo
info = My.Computer.FileSystem.GetFileInfo(file)
Dim attr As System.IO.FileAttributes
attr = info.Attributes
isEncrypted = ((attr And System.IO.FileAttributes.Encrypted) > 0)
End Function
但它根本不运行。任何人都有这方面的经验,或者有更简单的方法来检查加密吗?如果我尝试重命名和访问,访问会挂起并崩溃移动加密文件。
I'm building a form that moves files from one location to another based on data within the DB, and it works as long as the source file is not encrypted (green filename in windows explorer) and as long as the destination file does not exist.
So I'm trying to create the following:
Public Function isEncrypted(file As String) As Boolean
Dim info As System.IO.FileInfo
info = My.Computer.FileSystem.GetFileInfo(file)
Dim attr As System.IO.FileAttributes
attr = info.Attributes
isEncrypted = ((attr And System.IO.FileAttributes.Encrypted) > 0)
End Function
But it doesn't run at all. Anyone have experience with this, or is there an easier way to check for encryption? Access hangs and crashes if I try to rename & move an encrypted file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如其他人提到的,vb.net 代码不可能在 access 中编译。您很可能需要使用 win32 的系统调用来获取文件属性。 FileSystemObject(Scrrun.dll“Windows 脚本运行时”)对象也将不起作用,因为它的枚举不会告诉您文件是否已加密。这是一个 Windows API 函数,您可以使用它来确定文件是否加密。
As others have mentioned, there is no way that the vb.net code is going to compile in access. You will most likely need to use a system call from win32 to get the file attributes. The FileSystemObject (Scrrun.dll 'Windows Scripting Runtime') object will not work either as it's enumeration will not tell you if the file is encrypted. Here is a windows API function you can use to determine if the file is encrypted or not.