I'm making a script(python 2.7) to find all files in a directories and its subdirectories and then to fetch its last modification data.
In order to do this, I use the hardcoded path in os.walk to walk through the directories.
The problem is that some files produce the above-mentioned error when opened. The most common reason people run into this problem is because the path is not correctly joined, thereby causing the script to try and open a file that doesn't exist. This isn't the case for me.
After trying different combinations of directories, I began to notice a pattern whereby files that produce the error seem to have a deep directory structure and a long filename. I can't think of any other reason for the issue.
After searching for solutions I came across:
Adding "\\\\?\\" as a prefix to the path.
However it does not seem to work, Most probably because the file name may not be unicode. As this is a file accessed from the server, not much we can do about that.
The format of path that i am using is:
"//xyz.zone1.zifi.net/DavWWWRoot/sites/abc/1324324/mywork"
Any other solutions are appreciated?