Long File path Exception:The system cannot find the path specified
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 23 05:37:27 PDT 2017
On Wednesday, 23 August 2017 at 05:06:50 UTC, Vino.B wrote:
> Hi All,
>
> When i run the below code in windows i am getting "The system
> cannot find the path specified" even though the path exist ,
> the length of the path is 516 as below, request your help.
>
> Path :
> N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder
>
> Program:
> void SizeDirList (string[] SzDNDlst)
> {
> auto logF = File(LFpath, "a");
> ulong subdirTotal = 0;
> foreach (string i; SzDNDlst[0 .. $])
> {
> auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a
> => a.isDir && !globMatch(a.baseName, "*DND*")).array;
> foreach (d; dFiles)
> {
> auto SdFiles = dirEntries(d, SpanMode.breadth).array;
> foreach (f; SdFiles)
> {
> subdirTotal += f.size;
> }
> ulong subdirTotalGB = (subdirTotal/1024/1024/1024);
> if (subdirTotalGB > SizeDir)
> {
> writefln("%-63s %s", d, subdirTotalGB);
> }
> subdirTotal = 0;
> }
> }
> }
>
> From,
> Vino.B
Windows has a 260-character limit on file path names. This can be
disabled in Windows 10 for applications that ship with a
manifest, but that isn't going to help you. If the Phobos
functions are using the Win32 API internally, and specifically
the Unicode variants, then you should be able to get around this
by prepending "\\?" to any file path you send to the API. That's
how long file paths have been handled in Win32 to date. If it
doesn't work with Phobos, then you'll need to call Win32 directly
and Phobos should be modified.
More information about the Digitalmars-d-learn
mailing list