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

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 23 05:12:47 PDT 2017


On Wednesday, 23 August 2017 at 12:01:20 UTC, Vino.B wrote:
> On Wednesday, 23 August 2017 at 11:29:07 UTC, Moritz Maxeiner 
> wrote:
>>
>> On which line do you get the Exception? Does it happen with 
>> shorter paths, as well?
>> Assuming it happens with all paths: Just to be sure, is each 
>> of those backslashes actually encoded as a backslash? If you 
>> specified the path in the D source like `path = 
>> "N:\PROD_TEAM..."`, then it won't be, because backslash is an 
>> escape character (you would need to write `path = 
>> "N:\\PROD_TEAM..."`, or better yet path = "N:/PROD_TEAM..."`).
>
>   The above program scan for files/directories under the main 
> folder N:\PROD_TEAM\ and reports the size of each of the sub 
> folders eg: "TST_BACKUP", under the main folder "N:\PROD_TEAM\" 
> there are more than 9000+ files/directories, eg: 
> (N:\PROD_TEAM\TST_BACKUP,N:\PROD_TEAM\PRD_BACKUP\....)  and the 
> above program will output the size of the sub folders 
> "TST_BACKUP,PRD_BACKUP",  there is no issue is the path is 
> shorter, the issue arises only when the path is bigger, eg the 
> program prints the size of the sub folder PRD_BACKUP but when 
> it tries to scan the sub folder TST_BACKUP the issue arises and 
> the program terminates with the exception "The system cannot 
> find the path specified", hence it not not be possible to 
> provide the path explicitly, so can you help me on this.

While that is good to know, you still haven't answered my initial 
question:

>> On which line do you get the Exception?

If your program terminates because of an uncaught exception (as 
you stated), then you should've received a stack trace containing 
the line number on which the exception was thrown (remember to 
compile with debug info).
You should also consider providing a compilable, minimal example 
(with test data) that can be used to reproduce the issue.


More information about the Digitalmars-d-learn mailing list