Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How check for valid file name
Message
From
21/11/2000 03:38:04
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00443211
Message ID:
00443984
Views:
8
FUNCTION TestLegalFileName(tcFileNameToTest, tcTargetPath)
LOCAL cTempDir, nFH, cOldErrorHandler
IF TYPE('tcFileNameToTest') # 'C'
   RETURN .F.
ENDIF
cTempDir = ADDBS(FULLPATH(IIF(TYPE('tcTargetPath') # 'C' OR LEN(tcTargetPath) = 0,'.',tcTargetPath)))+SYS(3)
DO WHILE DIRECTORY(cTempDir)
   cTempDir = LEFT(cTempDir,RAT('\',cTempDir))+SYS(3)
ENDDO
cOldErrorHandler = ON('ERROR')
nFH = 0
ON ERROR nFH = -1
MKDIR (cTempDir)
IF nFH = 0
   nFH = FCREATE(cTempDir+'\'+tcFileNameToTest)
   IF nFH > 0
      *  OK
      =FCLOSE(nFH)
      ERASE (cTempDir+'\'+tcFileNameToTest)
   ENDIF
   RMDIR (cTempDir)
ENDIF
ON ERROR &cOldErrorHandler
RETURN nFH > 0
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform