creating sparse files on win32

Trent Mick trentm at
Tue Jul 15 19:49:22 CEST 2003

[erick_bodine at wrote]
> I need to create some sparse files on a win32 system (2000 & 2003
> Server) in order to do some testing of another application (not
> python).  I have been poking around the win32all extensions (win32file
> specifically) that come w/ ActivePython but can't find anything that
> allows me to create a file with the 'sparse file attribute' set.
> Has anyone done this in python?

I haven't done this but MSDN teels me here:
that one needs to use the FSCTL_SET_SPARSE control:

The code sample on the latter link uses the DeviceIoControl() Win32 API
    >>> import win32file
    >>> win32file.DeviceIoControl
    <built-in function DeviceIoControl>
Also use this to determine if the file system supports sparse files:
    >>> win32api.GetVolumeInformation
    <built-in function GetVolumeInformation>

Hopefully that can give you a start.


Trent Mick
TrentM at

More information about the Python-list mailing list