The maximum path name (Directory name) length in Windows-windows is 248 bytes

Source: Internet
Author: User

You can verify this upper value with the following C # code.

// ------------------------------------------------------------------------------------------------------------- -------//<copyright file= "Program.cs" company= "Chimomo ' s Company" >//Respect the work.//</copyright>//&L t;summary>//the program.//</summary>//----------------------------------------------------------------    ----------------------------------------------------namespace csharplearning{using System.IO;    <summary>//The program.        </summary> public static Class Program {///<summary>//the main. </summary> public static void Main () {directory.createdirectory (@ "D:\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t        \t\t\t\ "); }    }}

Above the code, the string D:\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ T\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ T\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ is exactly 247 bytes. , add one more character and you'll get an error:

Unhandled Exception:System.IO.PathTooLongException:The specified path, file name, or both is too long. The fully qualified file name must is less than 260 characters, and the directory name must is less than 248 characters.
At System.IO.Directory.InternalCreateDirectory (string fullPath, String path, Object dirsecurityobj, Boolean checkhost)
At System.IO.Directory.InternalCreateDirectoryHelper (String path, Boolean checkhost)
At System.IO.Directory.CreateDirectory (String path)
At CSharpLearning.Program.Main () in D:\My Project\learning\csharplearning\csharplearning\program.cs:line 24
Press any key to continue ...

This verifies that the maximum path length in Windows is 248 bytes (because Windows adds a "s" at the end of the path name). However, you can still manually make a path longer than 248 bytes, simply rename a folder in the path created by code above so that its folder name is longer than 1 bytes.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.