How to copy a file on Windows while preserving permissions

Andrew Koenig ark at acm.org
Thu Apr 12 16:49:39 EDT 2007


The answer to this question probably involves pywin32 or a similar library.

I would like to copy a file from one place to another on a Windows machine 
while preserving as much of the file permissions as it is possible to 
preserve with whatever my program's privileges happen to be.  If the file is 
a directory (i.e. folder), this might require temporarily granting myself 
write permission for the directory so I can (recursively) create files in 
it--again, assuming that it is possible to do so.

Obviously it would be necessary to determine whether my program's privileges 
are sufficient to solve this problem for the particular files in question.

Can someone who is more familiar than I with the vagaries of Windows file 
protection and the Python interfaces available to it point me in a useful 
direction?





More information about the Python-list mailing list