简体   繁体   中英

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. How can we set the root of a removable?

Code I use to set permissions on 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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