How to copy a file on Windows while preserving permissions

Discussion in 'Python' started by Andrew Koenig, Apr 12, 2007.

  1. 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?
     
    Andrew Koenig, Apr 12, 2007
    #1
    1. Advertising

  2. > 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?


    To copy a file along with its attributes, try SHFileOperation.

    Alternatively, if you have backup privileges, open the file for backup,
    then use BackupRead/BackupWrite.

    HTH,
    Martin
     
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=, Apr 12, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Beemer Biker
    Replies:
    0
    Views:
    296
    Beemer Biker
    Nov 8, 2006
  2. TTroy
    Replies:
    16
    Views:
    803
    Peter Nilsson
    Jan 31, 2005
  3. Mikhail T.
    Replies:
    6
    Views:
    331
    Mikhail T.
    May 14, 2007
  4. Replies:
    4
    Views:
    544
  5. George Sakkis

    Preserving file permissions with distutils

    George Sakkis, Jan 14, 2009, in forum: Python
    Replies:
    0
    Views:
    378
    George Sakkis
    Jan 14, 2009
Loading...

Share This Page