windows - Python os.listDir throws "WindowsError: [Error 5] Access is denied:" on some folders -
basically have fileexplorer class written in python 2.6. works great, can navigate through drives, folders, etc. however, when specific folder 'c:\documents , settings/.*'*, os.listdir, on script based, throws error:
windowserror: [error 5] access denied: 'c:\documents , settings/.'
why that? because folder read-only? or windows protecting , script cannot access?!
here offending code(line 3):
def listchilddirs(self): list = [] item in os.listdir(self.path): if item!=none and\ os.path.isdir(os.path.join(self.path, item)): print item list.append(item) #endif #endfor homecoming list
in vista , later, c:\documents , settings junction, not real directory.
you can't straight dir
in it.
c:\windows\system32>dir "c:\documents , settings" volume in drive c os volume serial number 762e-5f95 directory of c:\documents , settings file not found
sadly, using os.path.isdir()
, homecoming true
>>> import os >>> os.path.isdir(r'c:\documents , settings') true
you have @ these answers dealing symlinks in windows.
create ntfs junction in python symlinks in windows python windows file operating-system
No comments:
Post a Comment