Perl script to open a folder which contains a longfile name and shows an error "Could not open 'dir' for reading 'Filename too long'"
Asked
Active
Viewed 285 times
-2
-
filename should not be short only with the same filename it needs to be open. forget to add this point so I added in comments – Suhima K Jan 07 '21 at 05:35
-
1Could you pls show us what you have tried? You can edit the question and paste the code. See [minimal-reproducible-example](https://stackoverflow.com/help/minimal-reproducible-example) for more info. – vkk05 Jan 07 '21 at 05:36
-
1use `chdir()` to change to a subdirectory, so that the path to the file you want isn't as long. – Barmar Jan 07 '21 at 05:38
-
Could you name OS you use? https://www.codeproject.com/Questions/1002424/how-to-resolve-Filename-too-long-when-readdir-in-p suggest it is MX Windows specific problem fixed by use of Win32::LongPath – AnFi Jan 07 '21 at 05:48
-
This question deserves a really good answer from someone who understands the Windows filesystem and its APIs. It's not easy and it's a bit beyond me. – brian d foy Jan 07 '21 at 22:00
-
Ah, I'd asked a similar question before: https://stackoverflow.com/questions/1721807/how-do-i-create-then-use-long-windows-paths-from-perl – brian d foy Jan 13 '21 at 03:39
1 Answers
4
perl: handling long filenames in MS Windows
https://www.codeproject.com/Questions/1002424/how-to-resolve-Filename-too-long-when-readdir-in-p suggest it is MS Windows specific problem fixed by use of Win32::LongPath perl module.

AnFi
- 10,493
- 3
- 23
- 47
-
Thanks all for your answers who replied for my question I have used Win32::LongPath and it is working fine. – Suhima K Jan 07 '21 at 11:57