Re: MAX_PATH



Tracey wrote:

I remember perusing some files somewhere and saw something like:
if (os_ver >= some_num) ...
if (ie_ver >= some_num) ...

I wasn't sure if I had to test per version to find the MAX_PATH or if all
Windows OSs are the same.

In Win32, MAX_PATH is always 260. You should always be OK with code like this:
TCHAR path[MAX_PATH];
GetTempPath(MAX_PATH, path);

The NTFS file system in modern versions of Windows (such as XP and Vista) can handle file paths with up to 32,000 characters. The Unicode version of some of the system functions support such long paths, using a special \\?\ prefix. You may not be able to browse such a deep directory structure with Windows Explorer, and a lot of the API functions won't be able to handle such long paths. This doesn't affect MAX_PATH in any way. MAX_PATH is the shell's limit. 32,000 is the file system's limit. They're two different things.

Unless you're doing something extreme, you should be fine with MAX_PATH. I wouldn't recommend exceeding this limit, unless you have a very good reason. If you have to ask, assume that is the limit. MAX_PATH includes the terminating \0, so the actual number of useful characters in a file path is 1 less. So if you have to store the longest possible file path in a database, that's VARCHAR(259).

Tom
.



Relevant Pages

  • Re: renaming file
    ... Once you get the correct file path from that dialog, ... You can also use Windows Find or Search ... > You are confusing Internet Explorer and Windows Explorer. ... > When you have it running, select its Tools> Folder Options> View ...
    (microsoft.public.word.newusers)
  • RE: OVERLY LONG FILE NAMES - as impediment to COPYING FILES
    ... Can you shorten the names of all the folders so that the file path is shorter? ... >>> If the file saves to my C drive in Windows XP Professional, ... >>> But if it's available in Windows XP Professional or in XP Media Center, ...
    (microsoft.public.windowsxp.basics)
  • Re: Does Framework 2.0 trash COM for everyone else ?
    ... Server and almost every other Windows operating system is security. ... >> input file path, log file path, and a connection string. ...
    (microsoft.public.dotnet.framework)
  • Re: Scheduled Tasks used to work, but not now
    ... Regards, ... Dave Patrick ....Please no email replies - reply in newsgroup. ... Microsoft MVP [Windows] ... | is right in them because when I copy and paste the file path in the ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: file access under windows ce
    ... Your syntax looks ok. ... beitman AT applieddata DOT net ... I am new to windows ce application development. ... I want to know how to give file path of a file in windows ...
    (microsoft.public.windowsce.app.development)