Is there a function to check if a filename is valid?
Thanks in advance
Otto
Hi Otto:Otto wrote:Is there a function to check if a filename is valid?
If File( "YourFile" )
?"it exist"
else
?"not exist"
endif
// The example implements the function LongFileValid() which tests
// if a long file name is valid
PROCEDURE Main
? FileValid( "MyApp.prg" ) // result: .T.
? FileValid( "My New Application.prg" ) // result: .F.
? LongFileValid( "My New Application.prg" ) // result: .T.
RETURN
FUNCTION LongFileValid( cFileName, lExtension )
IF Valtype( lExtension ) <> "L"
lExtension := .F.
ENDIF
RETURN FileValid( cFileName, 255, 255, lExtension, .T. )
FUNCTION CheckFileName(cName)
LOCAL CharNo := {",","=","+","<",">","|","[","]","\","/"}
LOCAL cResult := .T.
FOR i=1 TO LEN(cName)
IF AT(CharNo[i],cName) <> 0
cResult := .F.
i := LEN(cName)
ENDIF
NEXT
MsgInfo("Filename is " + IF(cResult,"","not ") + "valid")
RESULT(cResult)
FileValid( <cFileName> , ;
[<nMaxName>] , ; // default 8. Assign 255 for long file names
[<nMaxExtension>], ; // default 3. Assging 255 for lfn
[<lNoExtension>] , ; // better retain the default .f.
[<lSpaces>] ) // default .f. . Assign .t. for long file names
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 45 guests