Alternate Data Streams on a folder
Question: I'm using StgCreateStorageEx from python win32com based adapting the code in
[testStorage.py](http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/file/9f6fdae45eb7/com/win32com/test/testStorage.py)
to write my own file_id attribute onto any file.

According to [alternate-
streams](http://www.flexhex.com/docs/articles/alternate-streams.phtml) (though
not necessarily from this API call) it should be possible to save to a
directory/folder, but changing the flags yield different errors, eg:

    
    
    from win32com import storagecon
    import pythoncom, os, win32api
    
    fname = r"c:\temp\test\test.txt" #works
    fname = r"c:\temp\test\test2"
    
    def testit():
        m=storagecon.STGM_READWRITE | storagecon.STGM_SHARE_EXCLUSIVE
        pss=pythoncom.StgOpenStorageEx(fname, m, storagecon.STGFMT_FILE, 0, pythoncom.IID_IPropertySetStorage)
    

results in:

> pywintypes.com_error: (-2147024895, 'Incorrect function.', None, None)

**EDIT:** Any suggestions on how to get this to work from both WinXP, Win7 and
Windows Server 2003/R2?

Note that the end result does not necessarily need to use this API, I just
need to be able to do it efficiently from Python. By efficiently I mean not
through many different technology layers.


Answer: It succeeds if storagecon.STGM_DIRECT is added to the mode.

