Long File path Exception:The system cannot find the path specified

Vino.B via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 25 09:40:11 PDT 2017


On Friday, 25 August 2017 at 09:08:44 UTC, zabruk70 wrote:
> On Thursday, 24 August 2017 at 18:02:24 UTC, vino wrote:
>>   Thanks for your support, was able to resolve this issue.
>
> Hello.
> IMHO, it will be better, if you will share your solution for 
> other peoples :)

Hi,

  Please find the solution below, basically i converted the path 
to UNC path as below

Solution:
auto unc = "\\\\?\\"~i;
    auto dFiles = dirEntries(unc, SpanMode.shallow).filter!(a => 
a.isDir && !globMatch(a.baseName, "*DND*")).array;

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Program:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import std.file: dirEntries, isFile, SpanMode, remove, 
rmdirRecurse, exists, mkdir;
import std.stdio: writeln, writefln, File;
import std.algorithm: filter;
import std.array: array;
import std.path: globMatch, baseName;
/**********************************************/
/* Global Valiables                           */
/**********************************************/
int SizeDir = 10;

/**********************************************/
/* Folder Lists                               */
/**********************************************/
auto SizeDirlst = [ "N:\\PROD_TEAM", "P:\\TEAM" ];
/******************************************/
/* Function : Size of Non DND Dir List    */
/******************************************/
void SizeDirList (string[] SzDNDlst)
{
  ulong subdirTotal = 0;
  foreach (string i; SzDNDlst[0 .. $])
  {
    auto unc = "\\\\?\\"~i;
    auto dFiles = dirEntries(unc, 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[0].replace("\\\\?\\", ""), 
subdirTotalGB);
  }
subdirTotal = 0;
  }	
}
}

/********************************************************************************************/
/* Main
                      */
/********************************************************************************************/
void main ()
{
  SizeDirList(SizeDirlst);
}


More information about the Digitalmars-d-learn mailing list