G
Guest
Hi,
Where in .NET are definded constants for maximal file name length and
maximal file path?
Thanks,
Lubomir
Where in .NET are definded constants for maximal file name length and
maximal file path?
Thanks,
Lubomir
Willy Denoyette said:| Hello Lubomir,
|
| On Windows-based platforms, paths must be less than 248 characters and
file
| names must be less than 260 characters.
Well I know it's documented like this in the .NET IO claas API's, but
unfortunately it's completely wrong.
The maximum path length is 260 characters maximum including a terminating 0
character.
The maximum file component length is 256 characters including a terminating
0 charecter.
A file path consists of following components:
- drive component (drive letter, a colon: backslash),
- directory components, and
- a file name component
So this "c:\255 chars. filename"
and this ".\255 chars. filename"
are valid paths...
while this is not: "c:\256 chars filename" ...
filename component exceeds 256 characters(excluding the 0 character)
That means that we can say that the largest filename component length is 255
characters, that is 260 characters - the drive component lenth - 1.
Willy.
Michael Nemtsev said:Hello Lubomir,
There is no constant for this. If u exceed the lenght of directory name u
just get exception
L> "Willy Denoyette [MVP]" wrote:
L>L> Hi,
L>
L> Thanks for answers. I am familiar with those numbers from C++6.0
L> projects, where I could use built-in constant MAX_PATH.
L>
L> Similar aproache I would like to use in C# projects. I want to avoid
L> using hardcoded number 260. I prefer to use constant provided by the
L> framework, but I don't know where are these constant defined. Are
L> there any at all?
L>
L> Thanks for help.
L>
L> Lubomir
L>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.