[python-win32] Problems with SetFileAttributes

Cioffi, Chris Chris.Cioffi at Anthem.com
Tue Mar 9 11:14:51 EST 2004


Hello all,

I'm writing a little app where I need to create some directories that I
would like to set the compressed flag on for Win2K.  However, neither
win32file.SetFileAttributes nor win32api.SetFileAttributes seems to work.
Here's what I've done to test:

import win32api
import win32con
import win32file

filename = 'c:\\inetpub\\docs'

def method1():

    print "use the win32api module to set the compress flag"

    attr = win32api.GetFileAttributes(filename)
    print 'Starting attrributes: %d' % attr

    new_attr = attr | win32con.FILE_ATTRIBUTE_COMPRESSED
    print 'New attributes: %d' % new_attr

    win32api.SetFileAttributes(filename, win32con.FILE_ATTRIBUTE_COMPRESSED)
    print 'Final attributes: %d\n' % win32api.GetFileAttributes(filename)
    return

def method2():


    print "use the win32file module to set the compress flag"

    attr = win32file.GetFileAttributes(filename)
    print 'Starting attrributes: %d' % attr

    new_attr = attr | win32con.FILE_ATTRIBUTE_COMPRESSED
    print 'New attributes: %d' % new_attr

    win32file.SetFileAttributes(filename, new_attr)

    print 'Final attributes: %d\n' % win32file.GetFileAttributes(filename)
    return

if __name__ == '__main__':
    method1()
    method2()

And I get the following back:
>>> use the win32api module to set the compress flag
Starting attrributes: 16
New attributes: 2064
Final attributes: 16

use the win32file module to set the compress flag
Starting attrributes: 16
New attributes: 2064
Final attributes: 16

This is ActivePython v2.3.2, build 159.  I do have admin rights to the whole
machine and the directory is empty.  Any info would be appreciated.

Chris Cioffi
Enterprise Technology Specialist
800-991-7259
Confidentiality Note: This message, including files attached to it, may
contain confidential information that is intended only for the use of the
ADDRESSEE(S) named above. If you are not an intended recipient, you are
hereby notified that any dissemination or copying of the information
contained in this message, or the taking of any action in reliance upon the
information, is strictly prohibited. If you have received this message in
error, please notify the sender immediately and delete the message from your
system. Thank you.




CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, 
is for the sole use of the intended recipient(s) and may contain confidential
and privileged information or otherwise protected by law.  Any unauthorized
review, use, disclosure or distribution is prohibited.  If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20040309/3638f5bb/attachment.html


More information about the Python-win32 mailing list