There are some folder with more than 100 files on it. But all files and folders names broken with wrong encoding names (UTF->ANSI).
"C:\...\Госдача-Лечебни корпус\вертолетка\Госдача-Лечебни корпус\Госдача-Лечебни корпус\вертолетка\Госдача-Лечебни корпус\вертолетка\Госдача-Лечебни корпус\Госдача-Лечебни корпус\Госдача-Лечебни корпус\вертолетка\Госдача-Лечебни корпус\Госдача-Лечебни корпус\вертолетка\Госдача-Лечебни корпус\..."
Regular function Utf8ToAnsi
finxing it, but FindFirst
can't search folders with names longer than 255 symbols.
It gaves me only 70/100 files.
To run the Path Length Checker using the GUI, run the PathLengthCheckerGUI.exe. Once the app is open, provide the Root Directory you want to search and press the large Get Path Lengths button. The PathLengthChecker.exe is the command-line alternative to the GUI and is included in the ZIP file.
FindFirst wraps the Win32 API function FindFirstFile, and the Unicode version of that function can search paths up to 32,767 characters long if you prepend \\?\
to the path you're passing in, like \\?\C:\Folder\Folder\*
.
Since Delphi 2009 and newer call the Unicode functions for you, you can just use FindFirst and co there. For Delphi 2007 and earlier (ANSI versions), you'll need to call FindFirstFile/FindNextFile/FindClose
from Windows.pas
directly. For more information check the Naming a file section of the platform SDK.
Do note that using \\?\
disables various bits of path processing though, so make sure it's a fully qualified path without any '.' or '..' entries. You can use the same trick to open file streams, rename, or copy files with longer paths.
The shell (Explorer) doesn't support this though, so you still need to limit those to at most MAX_PATH characters for things like SHFileOperation
(to delete to the recycle bin) or ShellExecute
. In many cases you can work around the problem by passing in the DOS 8.3 names instead of the long ones. FindFirst's TSearchRec doesn't expose the short names, but FindFirstFile's TWin32FindData
structure does as cAlternateFileName
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With