[python-win32] DIR reports file timestamp and size, but os.path.getctime(), os.path.getsize() raise WindowsError [Error 5] Access is denied

Mark Hammond skippy.hammond at gmail.com
Wed May 23 06:48:23 CEST 2012


On 22/05/2012 10:02 AM, python at bdurham.com wrote:
> Wondering if any of you have stumbled across the following behavior:
> I'm doing a recursive directory listing of my Windows folder and I can access
> the timestamps and file sizes of all files except the following 6 files:
> In the \windows\microsoft.net\framework\v2.0.50727\config folder:
> enterprisesec.config.cch.6824.14057640
> security.config.cch.6824.14057640
> In the \windows\\microsoft.net\framework64\v2.0.50727\config folder:
> \enterprisesec.config.cch.4412.14151427
> enterprisesec.config.cch.6912.14056844
> security.config.cch.4412.14151427
> security.config.cch.6912.14056844
> When I attempt to do any of the following on the above files, a WindowsError
> exception is raised with a value of "[Error 5] Access is denied: ...".
> os.path.getctime()
> os.path.getatime()
> os.path.getmtime()
> os.path.getsize()
> What's strange is that the DIR command from a cmd prompt returns timestamps and
> file sizes for the above files.
> Background; 64-bit Windows 7; 32-bit Python 2.7.2
> Any ideas on how I can retrieve timestamps and file sizes like DIR without
> raising exceptions?

You could try the win32api.FindFiles function.

Mark

> Thank you,
> Malcolm
>
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>




More information about the python-win32 mailing list