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

  • SEARCH
  • Home
  • 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 985759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:12:46+00:00 2026-05-16T05:12:46+00:00

What is the maximum amount of characters that a typical path can contain for

  • 0

What is the maximum amount of characters that a typical path can contain for a directory when using C#?

For example C:\test\ has 7 characters in length , what is the maximum length?

  • 1 1 Answer
  • 3 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-05-16T05:12:47+00:00Added an answer on May 16, 2026 at 5:12 am

    Maximum for MaxPath in CLR is 260 characters

    The maximum amount of characters is defined by MAX_PATH in the Win32 API library. This setting is 260 and that same setting is used, hard-coded, inside the CLR BCL. A path reaching that amount of characters is likely to cause trouble (see aside below). This maximum is the maximum for the good old FAT and FAT32.

    Conversely, the NTFS filesystem, used on the majority of Windows installations by default, has a maximum of 32767 characters and supports unicode (in an implementation where each character can take up 2 bytes, i.e., UCS-2, not UTF-32). But even in NTFS, a single path segment must not exceed 255 characters. While NTFS supports very long filenames, most applications, including any .NET application relying on System.IO, will not be able to see these filenames.

    Why 260 and not 256? Because the drive specifier, the first backslash and the trailing null-terminating character are not part of the length-limitations. You can get this information for Windows using GetVolumeInformation, which you should query for each volume individually (each volume can have a different max size).

    I assumed Windows. Linux and other OS’s may and will be different. Since Windows 10, build 1607, this limit has been removed, see below for details.


    As a general advice, you should not rely on any of these numbers. Instead, catch the PathTooLongException if you want to inform users that the path is too long:

    try
    {
        SetCurrentDirectory(longPath);
    }
    catch(PathTooLongException exc)
    {
        Console.WriteLine("The pathname was too long");
    }
    

    Note: the code above will throw when you exceed 260 characters, which is the limit that the CLR is imposing on you. This is not the real limit (see first paragraph).

    As an aside on .NET

    Microsoft has confirmed that it is a problem with the current implementation(s) of .NET that you cannot reliably find out what the maximum path size is as supported by the CLR. If you want to get this information programmatically, use the Path.MaxPath property. However, the property is internal which means you can only access it through reflection and that you cannot guarantee it will work across versions, or on other BCL implementations (Mono):

    // reflection
    FieldInfo maxPathField = typeof(Path).GetField("MaxPath", 
        BindingFlags.Static | 
        BindingFlags.GetField | 
        BindingFlags.NonPublic );
    
    // invoke the field gettor, which returns 260
    int MaxPathLength = (int) maxPathField.GetValue(null);
    

    Note: this gives you the maximum path as it is used by Microsoft’s .NET implementation. There’s a different value in the BCL for the maximum directory size, Path.MAX_DIRECTORY_PATH, but even inside the BCL this is never used. If you ever create a directory equal to this size, you will not be able to place any files inside that directory. Worse, just opening it will raise an error (because of the mandatory semi-directory aliases . and .., which causes many API’s to crash).


    UPDATE: as of Windows 10 Build 1607 you can remove the limit via OptIn in the Registry:

    Starting in Windows 10, version 1607, MAX_PATH limitations have
    been removed from common Win32 file and directory functions. However,
    you must opt-in to the new behavior.

    A registry key allows you to
    enable or disable the new long path behavior. To enable long path
    behavior set the registry key at
    HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled
    (Type: REG_DWORD).

    More info is in the updated entry on MSDN, section titled ‘Maximum Path Length Limitation’.

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

Sidebar

Related Questions

What is the maximum amount of characters that can be put into a textbox
How can I set the maximum amount of characters in a UITextField on the
I just want to set the maximum amount of characters per line, so that
Is there an maximum amount of data that can be stored in a single
Using IE6+, what is the maximum amount of text you can POST with a
What the maximum amount of characters a domain name can be? What about a
What's the maximum amount of heap space that one can allocate for java on
What factors determine the maximum amount of physical memory a system can have? I
I'm writing a Java application that needs to check the maximum amount of RAM
What is the maximum amount of data I can load onto a form control?

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.