locked
How do I get the value of MAX_PATH under C# RRS feed

  • Question

  • I'm writing an app in C# under VS2005. I know (at least I believe from my reading) that the maximum path length is "around" 260 characters and is defined by MAX_PATH. Where is MAX_PATH defined and can I retrieve it's value in my program?
    Thanks
    • Edited by PMBottas Sunday, April 12, 2009 5:48 PM typo
    Sunday, April 12, 2009 5:48 PM

Answers

  • Hi PMBottas,

    As far as I know, MAX_PATH defines the maximum character length of a path. MAX_PATH is defined as 260 characters for preventing buffer overflows. You could use this attribute to define a constant value in your program and use it, like:

    #define MAX_PATH 260
    typedef [string] CHAR PATH [MAX_PATH];
    

    For more information, please see following thread:

    Hope this helps,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by Nancy Shao Tuesday, April 14, 2009 5:04 AM Formatting
    • Marked as answer by Nancy Shao Friday, April 17, 2009 10:41 AM
    Tuesday, April 14, 2009 5:03 AM

All replies

    1. This isn't the right forum for this question, as it's a general C# question. This forum is for help with applications that extend the functionality of Visual Studio itself.
    2. What do you need MAX_PATH for? In general you shouldn't need it while working in C#.
    3. According to the documentation here, you define a const in your project with the value 260: http://www.pinvoke.net/default.aspx/kernel32/GetTempFileName.html

    :)
    Sunday, April 12, 2009 7:35 PM
  • Hi PMBottas,

    As far as I know, MAX_PATH defines the maximum character length of a path. MAX_PATH is defined as 260 characters for preventing buffer overflows. You could use this attribute to define a constant value in your program and use it, like:

    #define MAX_PATH 260
    typedef [string] CHAR PATH [MAX_PATH];
    

    For more information, please see following thread:

    Hope this helps,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by Nancy Shao Tuesday, April 14, 2009 5:04 AM Formatting
    • Marked as answer by Nancy Shao Friday, April 17, 2009 10:41 AM
    Tuesday, April 14, 2009 5:03 AM