473,378 Members | 1,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Maximal path and maximal file name length

Hi,

Where in .NET are definded constants for maximal file name length and
maximal file path?

Thanks,

Lubomir
Oct 11 '06 #1
6 21211
Hello Lubomir,

On Windows-based platforms, paths must be less than 248 characters and file
names must be less than 260 characters.

LHi,
L>
LWhere in .NET are definded constants for maximal file name length and
Lmaximal file path?
L>
LThanks,
L>
LLubomir
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
Oct 12 '06 #2

"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
| 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.
Oct 12 '06 #3
"Willy Denoyette [MVP]" wrote:
>
"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
| 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.

Hi,

Thanks for answers. I am familiar with those numbers from C++6.0 projects,
where I could use built-in constant MAX_PATH.

Similar aproache I would like to use in C# projects. I want to avoid using
hardcoded number 260. I prefer to use constant provided by the framework, but
I don't know where are these constant defined. Are there any at all?

Thanks for help.

Lubomir

Oct 12 '06 #4
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>
>"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microso ft.com...
| 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.
LHi,
L>
LThanks for answers. I am familiar with those numbers from C++6.0
Lprojects, where I could use built-in constant MAX_PATH.
L>
LSimilar aproache I would like to use in C# projects. I want to avoid
Lusing hardcoded number 260. I prefer to use constant provided by the
Lframework, but I don't know where are these constant defined. Are
Lthere any at all?
L>
LThanks for help.
L>
LLubomir
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
Oct 12 '06 #5
Hi Michael,

Thank you for help.
"Michael Nemtsev" wrote:
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>
"Michael Nemtsev" <ne*****@msn.comwrote in message
news:17***************************@msnews.microsof t.com...
| 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.
LHi,
L>
LThanks for answers. I am familiar with those numbers from C++6.0
Lprojects, where I could use built-in constant MAX_PATH.
L>
LSimilar aproache I would like to use in C# projects. I want to avoid
Lusing hardcoded number 260. I prefer to use constant provided by the
Lframework, but I don't know where are these constant defined. Are
Lthere any at all?
L>
LThanks for help.
L>
LLubomir
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
Oct 12 '06 #6

"Lubomir" <Lu*****@discussions.microsoft.comwrote in message
news:ED**********************************@microsof t.com...
| "Willy Denoyette [MVP]" wrote:
|
| >
| "Michael Nemtsev" <ne*****@msn.comwrote in message
| news:17***************************@msnews.microsof t.com...
| | 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.
|
|
| Hi,
|
| Thanks for answers. I am familiar with those numbers from C++6.0 projects,
| where I could use built-in constant MAX_PATH.
|
| Similar aproache I would like to use in C# projects. I want to avoid using
| hardcoded number 260. I prefer to use constant provided by the framework,
but
| I don't know where are these constant defined. Are there any at all?
|
| Thanks for help.
|
| Lubomir
|

There are no such constants defined in the FCL, the IO namespace classes are
wrappers arround the Win32 ANSI IO API's, so the same values apply. Anyway
when you exceed the max. path size you will get an exception thrown on you.
Note also that you can open files using the UNICODE version of the
CreateFile API through PInvoke, and use the file handle returned in a
FileStream instance, that way you can access files with a path name max. up
to 32768 bytes.

Willy.
Oct 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Saracen | last post by:
I have a major problem with trying to access a foxpro database from a web app. I have created a web app which is deployed on a server. The foxpro database (dbf) is on a different server. The...
10
by: farmer | last post by:
Request.Path will get the current Path name with file name such as: /Personal/Items.aspx How can I get the only Path name such as: /Personal
0
by: John Clark | last post by:
Hi, I am using webbrowser control to automate a site. this site contains form with tage <INPUT TYPE=FILE ...> I know the control is not writeable. So, only thing that I could do was: ...
1
by: MikeD | last post by:
Hi, I'm accessing a FoxPro database via ole db using Reporting Services Data Extensions and ths works fine on my local report server. However, when I deploy the report to the live report server...
2
by: freak | last post by:
Sorry , corrections to my script Have a problem with spaces in the function popen Next example works fine: ... $drive="c:"; $path=""; $file="\\myfile.exe"">"; $call = $drive.$path.$file;...
0
by: kamath10 | last post by:
Hi, Consider a scenario where there are a couple of notepads open say temp1.txt and temp2.txt. How do i programmatically get their full path name? regards Raghu
5
by: cssExp | last post by:
alright suppose i have the following. <input type="file" name="upload" /> <input type="text" name="discription" /> <input type="image" onclick="addFile();" src="images/addfile.jpg" name="add"...
1
by: mastro78 | last post by:
I'm using 2002 I defined my recordset as rWrkSheet Spreadsheet is the field in table Spreadsheets PathToExcelFiles is the full path where the Excel files i'm ref is stored ExcelFileName is the...
6
by: jaikris317 | last post by:
I have a C# project that connects to an Oracle server using ODBC Everything works fine if I keep the file name length less than 23 characters (including ".exe") If the executable file name...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.