Skip to content
Prev 57252 / 63421 Next

Writing files with long paths on Windows fails even after enabling long paths

Hello all,

We now can have long file paths on Windows by setting the LongPathsEnabled
key to 1 at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
in the Registry Editor. I can successfully rename files to have long paths
in File Explorer.

R still isn't able to take advantage of the change, however:

write(1, paste0(paste(sample(letters, 265, TRUE), collapse = ''), '.txt'))
#> Warning in file(file, ifelse(append, "a", "w")): cannot open file
#>
'mbpbzpgivtyhuugkkbcfxlvdzhsujaivaissyhivwqdxixmbnzctxlplazgtewpiioyxielkbohmvejcdkhcjmqtjyieymccrfquiwepngrseroiolayuucevztmqemnlnvfsshyhhggakxfemzzovwikusqtfeslwevxqmvufuyyvgvwwubmmpzvlcwaiwhipumrzphyeziwibisxszqrouekuonzjlaztdtonuupniqmxsaifpvkcldftkgnkozntgndwfu.txt':
#> No such file or directory
#> Error in file(file, ifelse(append, "a", "w")): cannot open the connection

I have read that long paths will be enabled by default in some future
release of Windows.

Hope this helps,
Kenny