Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9302239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:12:33+00:00 2026-06-18T23:12:33+00:00

When I recursive through some folders and files, I encounter this error: The specified

  • 0

When I recursive through some folders and files, I encounter this error:

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directoryname must be less than 248 characters.

Here’s my function

private void ProcessDirectory(DirectoryInfo di)
{
    try
    {
        DirectoryInfo[] diArr = di.GetDirectories();

        foreach (DirectoryInfo directoryInfo in diArr)
        {
            if (StopCheck)
                    return;
            ProcessDirectory(directoryInfo);
        }
        ProcessFile(di);
    }
    catch (Exception e)
    {
        listBoxError.Items.Add(e.Message);
    }

    TextBoxCurrentFolder.Text = di.ToString();
}

I cannot make the directory names shorter, because I’m not allowed too so… How can I solve this problem?

Added:
Here’s the other function:

private void ProcessFile(DirectoryInfo di)
{
    try
    {
        FileInfo[] fileInfo = di.GetFiles();

        if (fileInfo.LongLength != 0)
        {
            foreach (FileInfo info in fileInfo)
            {
                Size += info.Length;
                CountFile++;
            }
        }
    }
    catch (Exception e)
    {
        listBoxError.Items.Add(e.Message);
    }
}

EDIT
Found this where he used Zeta Long Paths:
How can I use FileInfo class, avoiding PathTooLongException?

Have implemented it and now i’m going to let the program run over the night to see if it works.

EDIT
Used the ZetaLongPath yesterday and it worked great! It even went through folders that needed permission access.

EDIT
Instead of zetalongPath, I’ve used Delimon.Win32.IO.dll which i think is much better. It has the same interfaces as Win32.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:12:34+00:00Added an answer on June 18, 2026 at 11:12 pm

    Here’s more info about the Delimon library referred to earlier. Its a .NET Framework 4 based library on Microsoft TechNet for overcoming the long filenames problem:

    Delimon.Win32.I​O Library (V4.0).

    It has its own versions of key methods from System.IO. For example, you would replace:

    System.IO.Directory.GetFiles 
    

    with

    Delimon.Win32.IO.Directory.GetFiles
    

    which will let you handle long files and folders.

    From the website:

    Delimon.Win32.IO replaces basic file functions of System.IO and
    supports File & Folder names up to up to 32,767 Characters.

    This Library is written on .NET Framework 4.0 and can be used either
    on x86 & x64 systems. The File & Folder limitations of the standard
    System.IO namespace can work with files that have 260 characters in a
    filename and 240 characters in a folder name (MAX_PATH is usually
    configured as 260 characters). Typically you run into the
    System.IO.PathTooLongException Error with the Standard .NET Library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically, this command does a recursive grep through all files in all sub-directories and
This recursive function ( search_Bases ) would hopefully iterate through each base class and
When looping recursively through folders with files containing spaces the shell script I use
I want to delete the cygwin folder and some other folders through powershell terminal
I was reading through some of the responses in this question and saw that
I am doing some exercises so that I can get through recursive stuff. One
I'm trying to recursively traverse through my Drive to search some files. The code
I loop through a bunch of directories recursively. Some of them (like D:\$RECYCLE.BIN\S-1-5-20 )
if I inject a recursive dependency through a constructor, then it gives me an
The problem: To create a recursive array function that walks through a three dimensional

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.