Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 962551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:31:32+00:00 2026-05-16T01:31:32+00:00

I’m looking at handling longer file paths in my windows application. Currently, I have

  • 0

I’m looking at handling longer file paths in my windows application.

Currently, I have a text box (edit box) in which a user can type an absolute file path. I then read that typed file path, using GetWindowText, into a string declared like so: TCHAR FilePath[MAX_PATH];

Obviously, here i’m relying on the MAX_PATH constant which limits me to 260 chars. So to handle longer file/paths names could I just extend my TCHAR array like this: TCHAR FilePath[32767];.

Or is there a better way? Could I use a variable length array? (TCHAR FilePath[]; is this even possible in C++? – sorry i’m pretty new to this).

Thank you in advanced!


Here’s the whole code snippet of what i mentioned above:

TCHAR FilePath[MAX_PATH];
ZeroMemory(&FilePath, sizeof(FilePath));
GetWindowText(hWndFilePath, FilePath, MAX_PATH);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:31:32+00:00Added an answer on May 16, 2026 at 1:31 am

    There are a number of limitations with respect to file paths on Windows. By default, paths cannot be longer than 260 characters, which is what the MAX_PATH constant is for.

    However, you can access longer paths – with certain limitations – by prefixing the path with “\\?\”. However, the limitations of using the “\\?\” prefix usually outweighs the benefit:

    1. There are a number of Win32 APIs that do no support paths with this prefix (for example, LoadLibrary will always fail on a path that is longer than 260 characters)
    2. The Win32 Canonicalization rules do not take effect when using the “\\?\” prefix. For example, by default, “/” in paths is converted to “\”, “.” and “..” are converted into references to the current and parent directories respectively and so on: none of that happens when you use the “\\?\” prefix.
    3. Just because you can modify your program to support longer paths, other programs may fail to open the files you’ve created. This will be the case if those other programs don’t also use the “\\?\” prefix.

    To be honest, point #2 is the real killer: you open yourself up to all sorts of trouble when using the “\\?\” prefix and you basically have to re-implement the Win32 canonicalization rules yourself if you go that route.

    Therefore, my recommendation is to just stick with the 260 limitation. At least until there’s better platform support for longer paths.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.