Error: File Path is Too Long

后端 未结 4 1095
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 17:57

i am trying to use the various file functions in C# like File.GetLastWriteTime, copy command on the file placed at the path greater than maximum allowed path on

4条回答
  •  长情又很酷
    2021-01-18 18:09

    http://www.codinghorror.com/blog/2006/11/filesystem-paths-how-long-is-too-long.html

    I recently imported some source code for a customer that exceeded the maximum path limit of 256 characters.

    The path you pasted was 285 characters long.

    As you noted in your comment, MSDN's link here (http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maximum%5Fpath%5Flength) explains this length in greater detail:

    In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\some 256-character path string" where "" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)

    With respect to the \\?\ functionality:

    Many but not all file I/O APIs support "\?\"; you should look at the reference topic for each API to be sure.

提交回复
热议问题