Path length in function file() ?
Moderator: Rathinagiri
-
- Posts: 22
- Joined: Wed Dec 20, 2017 8:29 am
- DBs Used: DBF
- Location: Belgium
Path length in function file() ?
Hello everybody,
It seems that the file() function does not accept a path longer than 56 characters?
example:
x := file ("c:\folder\subfolder\subfolder\somefile")
result --> x = .F. if length of c:\folder\subfolder\subfolder\ > 56
Windows 7 supports 260 characters, but I can not find any specification in the Harbour doc.
Somebody knows what?
It seems that the file() function does not accept a path longer than 56 characters?
example:
x := file ("c:\folder\subfolder\subfolder\somefile")
result --> x = .F. if length of c:\folder\subfolder\subfolder\ > 56
Windows 7 supports 260 characters, but I can not find any specification in the Harbour doc.
Somebody knows what?
- serge_girard
- Posts: 3169
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Path length in function file() ?
Hi Dominque,
On w7 if tested a file of +100 len
And it gave OK!
I'll try on my w10 later.
Serge
On w7 if tested a file of +100 len
Code: Select all
cFILE := 'P:\CDS\Allan Holdsworth-Alan Pasqua-Jimmy Haslip-Chad Wackerman\Blues for Tony Disc 1\01 Blues for Tony.WMA'
IF FILE(cFILE)
MSGINFO('OK')
ELSE
MSGINFO('NOK')
ENDIF
I'll try on my w10 later.
Serge
There's nothing you can do that can't be done...
- serge_girard
- Posts: 3169
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Path length in function file() ?
On w10 also OK!
Are you sure to check for the right filename?
Serge
Are you sure to check for the right filename?
Serge
There's nothing you can do that can't be done...
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: Path length in function file() ?
En xp es correcto
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no.
-
- Posts: 22
- Joined: Wed Dec 20, 2017 8:29 am
- DBs Used: DBF
- Location: Belgium
Re: Path length in function file() ?
Hello Serge,serge_girard wrote: ↑Tue Apr 23, 2019 3:10 pm On w10 also OK!
Are you sure to check for the right filename?
Serge
Yes, I am sure. I have tested with a path of variable length by adding one character at a time and with always de same filename, len 15 characters.
file() return .T. but arrived at 56 characters the function returns .F.
I am on W7.
So, I will continue to search.
Dominique
Re: Path length in function file() ?
Please, do a simple test:
Code: Select all
#include "hmg.ch"
PROCEDURE Main
Local cPath := hb_CWD() + "folder 1234567890\ABCDEFGH ijklmn\123 456\__________\+_+_+_+_+_+_+_+_+_+_+_+_+_+\(^)(^)(^)(^)(^)(^)(^)(^)(^)(^)\!@!@!@!@!@!@!@!@!\"
Local cFile := "test 1234567890 abc DEF.txt"
IF ! hb_DirBuild ( cPath )
MsgStop ( "Error creating the folders." )
ENDIF
IF StrFile ( cPath + cFile, cPath + cFile ) < Len ( cPath + cFile )
MsgStop ( "Error creating the file." )
ELSE
MsgInfo ( "Your file: " + cPath + cFile )
ENDIF
MsgDebug ( "File():", File ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) )
MsgDebug ( "hb_FileExists():", hb_FileExists ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) )
Return
-
- Posts: 22
- Joined: Wed Dec 20, 2017 8:29 am
- DBs Used: DBF
- Location: Belgium
Re: Path length in function file() ?
Your example works fine, thank you.edk wrote: ↑Tue Apr 23, 2019 6:36 pm Please, do a simple test:Code: Select all
#include "hmg.ch" PROCEDURE Main Local cPath := hb_CWD() + "folder 1234567890\ABCDEFGH ijklmn\123 456\__________\+_+_+_+_+_+_+_+_+_+_+_+_+_+\(^)(^)(^)(^)(^)(^)(^)(^)(^)(^)\!@!@!@!@!@!@!@!@!\" Local cFile := "test 1234567890 abc DEF.txt" IF ! hb_DirBuild ( cPath ) MsgStop ( "Error creating the folders." ) ENDIF IF StrFile ( cPath + cFile, cPath + cFile ) < Len ( cPath + cFile ) MsgStop ( "Error creating the file." ) ELSE MsgInfo ( "Your file: " + cPath + cFile ) ENDIF MsgDebug ( "File():", File ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) ) MsgDebug ( "hb_FileExists():", hb_FileExists ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) ) Return
Now I found the problem :
The pathname was not the problem but . . .
filename was not trimmed and with trailing blanks len (pathname + filename) > 260
It's better just to laugh . . .
Dominique
Re: Path length in function file() ?
Sometimes it happens that an obvious mistake is difficult to notice.