none
PathTooLongException: The Specified path, file name or both are too long

    Pregunta

  • Hi All:
    When I create a directory by System.IO.Directory.CreateDirectory method, I met an exception.

    I have checked the path parameter "\\cqaautob01n06.carmine.lab\D$\loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName"

    The total length of the path is "254" and the directory name length is 237 which are both less than the max characters length. But why the  exception happened?

    Also if I do not use the network path but the local path such as "d:\loooooooooooooooooooooo....." to create the same dicrectory it could be created successfully.

    I have tried that if I remove the domain part in the path it could be created successfully. path : \\cqaautob01n06\D$\looooooooo......

    — EXCEPTION #1/2 [PathTooLongException]
    Message = “The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.”
    ExceptionPath = Root.InnerException
    ClassName = System.IO.PathTooLongException
    HResult = COR_E_PATHTOOLONG=800700CE
    Source = mscorlib
    StackTraceString = “
    at System.IO.Path.SafeSetStackPointerValue(Char* buffer, Int32 index, Char value)
    at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
    at System.IO.Path.NormalizePath(String path, Boolean fullCheck)
    at System.IO.Path.GetFullPathInternal(String path)
    at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity)
    at System.IO.Directory.CreateDirectory(String path)

    martes, 07 de julio de 2009 6:09

Respuestas

Todas las respuestas

  • The share name is part of the directory name, you've therefore got 254 chars in the directory name.  Too many.
    Hans Passant.
    • Propuesto como respuesta Geert van Horrik jueves, 09 de julio de 2009 7:40
    • Marcado como respuesta Zhi-Xin Ye lunes, 13 de julio de 2009 15:19
    martes, 07 de julio de 2009 8:44
  • This is a .NET Library wirtten against .NET Framework 2.0 and can be used to
    access very long folder and files from a .NET application.
    http://gallery.technet.microsoft.com/DelimonWin32IO-Library-17cc7893


    Since the .NET Framework does not support long filenames :-(
    I had to write a library that calls the WIN32 API and wraps those
    functions like System.IO.  While it is not a complete replica of the
    System.IO it does have most objects and functions available.

    Delimon.Win32.IO replaces basic file functions of System.IO
    with long path names support for characters up to 32,767 Characters
    So bye bye MAX_PATH problem

    Did you ever run into this problem?
    System.IO.PathTooLongException

    was unhandled.  Message="The specified path, file name, or both are too
    long. The fully qualified file name must be less than 260 characters, and the
    directory name must be less than 248 characters."


    - Belgian Unified Communications Community : http://www.pro-lync.be -

    martes, 13 de marzo de 2012 1:04
  • Long Path Tool helped me in this situation. http://PathTooDeep.com
    martes, 09 de octubre de 2012 8:14