C++ WinAPI: handling long file paths/names

前端 未结 3 1905
日久生厌
日久生厌 2021-01-12 04:06

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

3条回答
  •  北海茫月
    2021-01-12 04:40

    It depends on what kind of program you're writing. My own strategy has usually been to restrict path creation to MAX_PATH in length, but be able to read existing data from longer paths (using the "\\?\" prefix Dean mentions in his answer). There are exceptions to that though -- just for example, a backup program should accept long paths, and must reproduce exactly what it was given as input.

    While Dean is certainly correct that Windows does not canonicalize longer paths for you, I have not found this to be much of a concern as a general rule. This doesn't generally mean writing your own code to canonicalize the path either -- it generally means having the user enter paths in a way that simply don't generate such things in the first place.

提交回复
热议问题