-1

I'm working in a project that stores files with very long paths.

I need to use network paths such as \\server\share\files.. paths. But I cannot figure out why its not working. I'm running Win7

\\server\share\path\file.exe ( This works but not for very long paths ~266 char long)

This wiki page https://en.wikipedia.org/wiki/Path_%28computing%29 specifies that syntax \\?\UNC\server\share\path\file.exe should work for longer paths but I can't get it to work for either long or short paths.. Not supported for Win7 ?

Anyone has a solution of how i can point to long network paths using a \\xxx syntax with length ~266 characters?

graN
  • 34
  • 6
  • The syntax works as shown on Windows 7. The most likely cause of your problem is that you are not using the Unicode API functions, the ANSI API functions do not have long path support. If that doesn't resolve the issue, please post example code. – Harry Johnston Feb 05 '16 at 23:39
  • For e.g. opening this (masked) path in Windows Explorer does not work.. neither if I, in the cmd-prompt, write "more "... The path: \\?\UNC\xx.xxxxxxx.xxx\xxxxxxxxxx\xxx\xxxxxx\xx_xxxx\xx\xxxxxxx\xxxx\xxxxxx.xxxxxxxx\20160204_150537_251895\xxxxxxxx_xxxx\xxx2x2150_xx-xxx687_20131010_103748\xxxxxxxx\xxx_xxx_xx_xx_2072212_xx_xxx_13411218_xx_xxx_14_1_xxxxxxx2_xxx_2012305x_xx_xxxx_xxx_xxxxxxx_2014542x.csv – graN Feb 08 '16 at 13:31
  • 2
    No, Explorer doesn't support long file paths, and neither do most of the command interpreter's built-in commands. But it should work in your application, provided you use the Unicode API. (One oddity is that the command interpreter accepts the long-path syntax for local drives, provided the path isn't actually too long, but does not accept the long-path syntax for UNC paths at all. I'm not sure of the significance of that.) – Harry Johnston Feb 08 '16 at 21:11

1 Answers1

1

Thanks to Harry Johnston, as a summary to how I solved my problem:

  • Windows Explorer does not support then \\?\UNC\.. syntax.
  • Using \\?\UNC\server\folder\.. together with Python 3.4 and shutil.copy2() works perfectly fine. (Which I assume uses the mentioned Unicode API from comments above)

when presenting the user with a directory path i remove ?\UNC\ and leave them with a simple \\server\path\.. path.. (which they, if they want to, copy paste into windows explorer and open the directory.

graN
  • 34
  • 6