Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File exist test
Message
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Title:
Miscellaneous
Thread ID:
00678971
Message ID:
00679922
Views:
18
Hi,

>I run FPD in win9x env. I want to put a file in system directory and I want to test if he exist in that place
>How can I do that ?
>I dont found any command for that.
>Somebody can help me ?

I usually use SYS(2000) to check for the existance of a file. Since you're not running a Windows application, you can't really use Windows-API functions to determine the Win system directory. So the suggestion of using GETENV() might be the only solution. You should then try to check for the different system directories. Some Win versions have a "system", some a "system32" and some both directories. The code is typed here, so it is not tested, but should help.
PRIVATE cWinSysDir
cWinSysDir = ""

*-- Find out win sys directory

*-- Check for "system32" directory
IF NOT EMPTY(SYS(2000, GETENV("WINDIR") + "\system32\*.*"))
  *-- Use "system32"
  cWinSysDir = GETENV("WINDIR") + "\system32\"
ELSE
  *-- Check for "system" directory
  IF NOT EMPTY(SYS(2000, GETENV("WINDIR") + "\system\*.*"))
    *-- Use "system"
    cWinSysDir = GETENV("WINDIR") + "\system\"
  ENDIF
ENDIF

*-- Check for your file

IF NOT EMPTY(SYS(2000, cWinSysDir + "yourfile.txt"))
  *-- File exists
ELSE
  *-- File doesn't exist
ENDIF
HTH,
Armin

Armin Neudert
Regional Director (Stuttgart) of German FoxPro User Group dFPUG

MCP for Visual FoxPro

Expert/Editor of the VFP section in the German Codezone community portal
Previous
Reply
Map
View

Click here to load this message in the networking platform