简体   繁体   English

Python Win32API SetFileAttributes For Removables

[英]Python Win32API SetFileAttributes For Removables

I'm writing an app to set attributes of pen drives.我正在编写一个应用程序来设置笔式驱动器的属性。 I could set all the files and subfolders with "normal" permissions.我可以使用“正常”权限设置所有文件和子文件夹。 But when I try setting the root path (like "k:/"), it doesn't work.但是当我尝试设置根路径(如“k:/”)时,它不起作用。 How can we set the root of a removable?我们如何设置可移动的根?

Code I use to set permissions on Windows:我用来在 Windows 上设置权限的代码:

win32api.SetFileAttributes("k:/", win32con.FILE_ATTRIBUTE_NORMAL)

The root path is not a file or a folder, and doesn't have attributes strictly speaking.根路径不是文件或文件夹,严格来说没有属性。 Are you trying to set the attribtues of all files and folders?您是否正在尝试设置所有文件和文件夹的属性? If so, you may want to loop through all files and folders in the root directory using os.listdir如果是这样,您可能希望使用 os.listdir 遍历根目录中的所有文件和文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM