CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2002
    Location
    cosmos
    Posts
    148

    How long full path of a file may be...?

    Hi, Pros!
    I need to write to a file a full path of that file. But how long path may be.
    I'm asking because I need to know maximum size which path takes in order
    properly structure the innards of the file.
    What doesn't kill us makes us stronger. F.Nietzsche.

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: How long full path of a file may be...?

    use MAX_PATH ( it's a #define in windows header file )

  3. #3
    Join Date
    May 2005
    Location
    United States
    Posts
    263

    Re: How long full path of a file may be...?

    Quote Originally Posted by kirants
    use MAX_PATH ( it's a #define in windows header file )
    Which is 260 characters.

    -Greg Dolley

  4. #4
    Join Date
    Oct 2002
    Location
    cosmos
    Posts
    148

    Re: How long full path of a file may be...?

    There is a problem. Imagine you have a file which is very deeply in directory
    tree. You can place a file as deep as you wish. Yes? Ok. If you can
    bury a file so deep then it's path grew very long, isn't it. If so my path will
    be more then 260 characters long? Or maybe I miss something?
    What doesn't kill us makes us stronger. F.Nietzsche.

  5. #5
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: How long full path of a file may be...?

    Quote Originally Posted by sulacco
    If you can bury a file so deep then it's path grew very long, isn't it.
    As you say, If you can. So, question is, have you been successful in doing it?

  6. #6
    Join Date
    Feb 2002
    Posts
    4,640

    Re: How long full path of a file may be...?

    There is a problem. Imagine you have a file which is very deeply in directory tree. You can place a file as deep as you wish. Yes? Ok. If you can
    bury a file so deep then it's path grew very long, isn't it. If so my path will
    be more then 260 characters long? Or maybe I miss something?
    Well, if the Windows API won't support paths longer then 260 characters (MAX_PATH), I would think that this is not an issue (since you can't do it).

    Viggy

  7. #7
    Join Date
    Oct 2002
    Location
    cosmos
    Posts
    148

    Re: How long full path of a file may be...?

    Ok. I will check it right now....wait...
    What doesn't kill us makes us stronger. F.Nietzsche.

  8. #8
    Join Date
    Aug 2004
    Posts
    184

    Re: How long full path of a file may be...?

    I think this is possible to do, but you have to really want to do it.

    First create a very deep directory structure.

    Then using a utility like junction from Sysinternals create a symbolic link to the deepest directory.

    Then accessing this directory from the symbolic link continuing creating your deep directory structure.

    In the end you should end up with a directory path that is longer than 260 characters.

    To access that directory I think you have to preappend the path with

    \\\\?\\

    so something like \\\\?\\c:\\...your really long path here\\mytextfile.txt

    HTH

  9. #9
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: How long full path of a file may be...?

    One filename (e.g. myfile.txt) can have a maximal length of 255 unicode character under NTFS. Although the complete path name can have a maximum length of 32,767 unicode characters. See this for info and comparison.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured