I have a problem when programming in Python running under Windows. I need to work with file paths that are longer than 256 or whatsathelimit. Now I read mainly about two solutions:
- Use GetShortPathName from kernel32.dll and access the file this way.
This is good, but I cannot use it, since I need to use paths in the path
shutil.rmtree(short_path)
where short_path is really a short path (something like D:\tools\Eclipse ), and long paths appear in the directory itself (damn Eclipse plugins).
- Prepare
"\\\\?\\" for the path
I was not able to do this job. Attempting to do something this way always results in a WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: <path here> error WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: <path here>
So my question is: how to make the second option work? I emphasize that I need to use it in the same way as in the example in option No. 1.
OR
Is there another way?
EDIT: I need a solution to work in Python 2.7
EDIT2: question Support for a long Python file name, corrupted on Windows , gives an answer with a "magic prefix", and I stated that I know this in this question. What I do not know is HOW to use. I tried to add this path to the path, but it just failed, as I wrote above.
python windows
Jiří kantor
source share