Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

easy question for you guru's 5

Status
Not open for further replies.

inteleserve

IS-IT--Management
Dec 13, 2002
75
US
I need fox to simply delete a file such as c:/datastore/test.dbf without using it. Just to simply remove it off my hard drive.. without using the command

delete file c:/datastore/test.dbf


Thanks,

The person who hates the delete file command.....
 
how bout:

Erase c:\Somefile.txt

:)

Ali Koumaiha
TeknoSoft Inc
Farmington Hills, Michigan
 
Why do you hate delete file command?

Use ERASE command instead?

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
Another option would be:

Code:
FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFile("c:\test.txt",.t.)


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
inteleserve,

Just out of interest, what is your objection to DELETE FILE? It is the obvious and most direct method of deleting files, and has the added benefit of letting you send the file to the recycle bin.

The only problem with it is that if you are trying to delete a DBF which is in a DBC, you will get an error next time you open the DBC. In that case, you should use DROP TABLE.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
At the risk of sounding rude and somewhat unprofessional...
it is certainly a pet peeve of mine when a member asks a question and several members respond (taking some of their own valuable time to be helpful) and then there is no response back from the original poster.

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
I had the same thought, Craig.
-----

Regarding DELETE FILE and ERASE, it can be a pain to trap the error they might throw (of course, VFP8's TRY..CATCH does the trick there...)

I had started using the winapi (no scripting COM objects to worry about) in VFP6:
Code:
***********************************************************
* SafeDel - Returns .T. if the file was deleted successfully
*          (DeleteFile returns 0 if there is an error)
PROCEDURE SafeDel
LPARAMETERS pcFile
DECLARE INTEGER DeleteFile IN kernel32 ;
  STRING lpFileName
res = DeleteFile(pcFile)
RETURN res<>0
 
Everyone thank you for your valuable posts. Especially you Craig, you have helped me learn that yes, people are taking up their valuable time, helping me out with problems when they do not even know me. I apologize for being selfish and inconsiderate of others and in the future will try to show more appreciation to all the programmers at tek-tips.com

[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top