os.path.getmtime on windows, error: 206 - path or extension too long

mynthon mynthon1 at gmail.com
Wed Jan 21 11:50:53 CET 2009

I have very long path on windows and i get error when try to get
modification time. So i tried do chdir path and then get file. It now
gives me error that file doesn't exists

# code
def getmtimeWIN32(p):
    mycwd = os.getcwd()

    if p.startswith('\\\\?\\'):
        p = p.replace('\\\\?\\', '', 1)

    p = os.path.splitdrive(p)
    r = p[0] # root - dir name
    p = p[1]
    p = os.path.split(p)
    f = p[1] # filename
    d = p[0]
    l = d.split('\\');

    if r != '': # if root is not empty change to root (it not works
when script is on other partition than file)

    for i in l:
        if i != '':
            #print i
    print os.getcwd()
# /code

it works for other files so i suppose it is not my fault. I know there
is a win32 module but i can't find any documentation for it (what is
the purpose to create app without docs?). Any idea?

I searched google but there where only 2 options. Use chdir (not
working) or use win32api (where is no documentation).

(python 2.5)

More information about the Python-list mailing list