English 中文(简体)
Is there any length-limits of file path in NTFS?
原标题:

Why can not I create a deep path whose characters in path is more than 255 in NTFS File System? It seems a limits of FAT32, but also exist in NTFS? Can anyone provide some documents?

Many Thanks!

最佳回答

The 260 character limitation is not a limitation of the file system, but of the Win32 API. Win32 defines MAX_PATH as 260 which is what the API is using to check the length of the path passed into functions like FileCreate, FileOpen, etc. (which are used by .NET in the BCL).

However, you can bypass the Win32 rules and create paths up to 32K characters. Basically you need to use the "\?C:MyReallyLongPathFile.txt" syntax which you may not have seen before. Last I checked, the File and FileInfo classes in .NET prevented you from using this type of path, but you can definitely do it from C/C++. Here s a link for more info.

http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

问题回答

Quoted from wikipedia

File names are limited to 255 UTF-16 code words. Certain names are reserved in the volume root directory and cannot be used for files. These are: $MFT, $MFTMirr, $LogFile, $Volume, $AttrDef, . (dot), $Bitmap, $Boot, $BadClus, $Secure, $Upcase, and $Extend;[3] . (dot) and $Extend are both directories; the others are files. The NT kernel limits full paths to 32,767 UTF-16 code words.

http://en.wikipedia.org/wiki/NTFS

Doc. You should certainly be able to create longer filepaths than 255 bytes, as long as each individual path component is under that. However you must be using the Unicode (W) versions of the file access calls to get this behaviour; if you re using the ANSI (A) byte-based interfaces such as those used by stdio, you ll be stuck with the limitations of the old pre-Unicode path interface.





相关问题
Code snippet paths in GCC

Background: Keil C51 on a PC, currently moving to GCC (CrossPack-AVR) on an iMac. Since I write firmware for micro s I have a lot of driver source files etc. that I need to include with my programs,...

C#/.NET app doesn t recognize Environment Var Change (PATH)

In my C# app, I am programmatically installing an Oracle client if one is not present, which requires adding a dir to the PATH system environment variable. This all works fine, but it doesn t take ...

PHP absolute path to file URI

In order to refer to a local DTD when using PHP SimpleXML, I need to convert the absolute path into a file type URI. For example, convert /home/sitename/www/xml/example.dtd to file:///home/sitename/...

Check if files with absolute and relative path exists

Is there a way to check whether files (with either an absolute or relative path) exists? Im using PHP. I found a couple of method but either they only accept absolute or relative but not both. Thanks.

How to get file path of the file with the running-vba code

I want to get the folder path from the file who is running the vba-code. For example: the vba-code is in the file C:myfolderfile.accdb and I want the vba-code to return C:myfolder Is that ...

热门标签