Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I delete a file with a leading space?
Message
From
20/08/1999 10:09:55
 
 
To
20/08/1999 10:01:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00255531
Message ID:
00255846
Views:
16
>>>>>I have a situation where there are some files created that have a leading space, eg. " JUNK.DBF". Is there a way to delete this file programmaticly using VFP5? Delete file, !del, and RENAME seem to have no affect. I am able to delete them with Explorer but I don't want the user to have to deal with it.
>>>>>
>>>>>Thanks!
>>>>
>>>>Have you tried using VFP's ERASE with name expansion? Try something like:
>>>>
>>>>ERASE (FULLPATH(' JUNK.DBF'))
>>>
>>>Nope, I get a file does not exist notice.
>>
>>Are you certain that the leading character is a space? I can get the following to work:
>>
>>cVar = 'this is dummy text'
>>=STRTOFILE(cVar, ' JUNK.DBF')
>>ERASE (' JUNK.DBF')
>>
>>with no problem under VFP6 with SP3 installed, at least under NT. I haven't tried it under Win9x.
>
>Hi Ed,
>
>Doesn't work with VFP5a version date 10/21/1997. < shrug >

You have several options open - the WSH has an automation object, Scripting.FileSystemObject, which provvides an ActiveX interface to the Shell functionality for deleting files. You could also try using the API call DeleteFile:
 DECLARE INTEGER DeleteFile IN KERNEL32 STRING @ lpFilename
IF DeleteFile(' Junk.DBF') # 0
   * it worked
ELSE
   * it didn't
ENDIF
>
>Jim
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