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 11:40:06
 
 
To
19/08/1999 21:17:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00255531
Message ID:
00255890
Views:
19
This works for me:
oFile = fCreate("C:\ junk.dbf")
fClose (ofile)

x1='!del c:\junk~1.txt'
&x1





>>>I have a situation where there are some files created that have a leading space, e.g. " JUNK.DBF". Is there a way to delete this file programmatically 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!
>>
>>I would like to know how someone was able to start a file name with a space. You can probably enclose the name in quotes to do it -- erase " junk.dbf"
>>
>>Can you do a X = Getfile(), then do a ? asc(left(X,1)) to see what it is?
>
>
>Hi Mark,
>
>Nope, it doesn't delete the file. The problem is in some code I've inherited. It's a cost accounting program, creates a table each month for the fiscal year as the person enters a new month. There is a prototype table and the new tables are copied from that. JUL_99CA, AUG_99CA etc. Apparently there is a certain set of steps that will create a table " _99CA.DBF" My problems is that I want to go through past FYs and when I do an ADIR and then loop through the array it bombs on the bogus table.
>
>I can go through and delete all the bogus tables but that doesn't assure that they won't get recreated by whatever means. I would like to delete them through Fox code but nothing seems to work.
>
>Here's a process that will create a file that Fox won't delete.
>
>oFile = fCreate("C:\ junk.dbf")
>fClose (ofile)
>
>oFile = fCreate("C:\results")
>
>ADIR(arr,"*.dbf")
>cName = arr(1,1)
>nCount = len((cName))
>
>FOR i = 1 to nCount
> ? (substr(arr(1,1),1,i))
> ? asc(substr(arr(1,1),i,1))
>ENDFOR
>
>? "'"+cName+"'"
>!del (cName)
>erase(cName)
>delete file (cName)
>
>? ADIR(arr,"*.dbf")
>? (oFile,(arr(1,1)))
>
>fClose(oFile)
>
>The output is:
>
>
> 32
>
> 32
> J
> 74
> JU
> 85
> JUN
> 78
> JUNK
> 75
> JUNK.
> 46
> JUNK.D
> 68
> JUNK.DB
> 66
> JUNK.DBF
> 70
>' JUNK.DBF'
>
>
>The file’s still there!! I just found that I can:
>
> !ren ??junk.dbf xxx.dbf
> delete file xxx.dbf

>
>Any other ideas?
Peter Cortiel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform