I have the following situation. I create a text file from a table that meet
a certain condition. I'm using the following command.



COPY TO ( cOutput ) FOR STORE <> "CA" TYPE SDF



IF no records meet the condition then FoxPro creates a file with zero bytes.



The problem that I'm having is that I cannot delete this file until I'm
completing out of FoxPro.



Here's the error that I'm getting.



There has been a sharing violation - The source or destination file may be
in use.



Does anyone know how I go about closing the file so that I can erase it in
the program?



Thanks

Re: UNABLE TO ERASE A FILE by Cindy

Cindy
Tue Feb 03 19:55:34 CST 2004

In news: eL$l7Ep6DHA.1804@TK2MSFTNGP12.phx.gbl,
Joaquin <jlopezh@earthlink.net> wrote:
> COPY TO ( cOutput ) FOR STORE <> "CA" TYPE SDF

How about testing first to see if there are any records that match the
filter?

SELECT COUNT(*) ;
FROM MyTable ;
INTO ARRAY laTemp ;
WHERE Store <> "CA" ;

IF laTemp[1] > 0
COPY TO .....
ENDIF

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org www.cindywinegarden.com




Re: UNABLE TO ERASE A FILE by Joaquin

Joaquin
Wed Feb 04 15:33:32 CST 2004

Cindy,

Thank you for your responds.

Yes this a nice workaround; however, I was just wondering why if anyone else
had encouter this problem and would this be consider a bug in Foxpro.


"Cindy Winegarden" <cindy.winegarden@mvps.org> wrote in message
news:OQaQBMs6DHA.2760@TK2MSFTNGP09.phx.gbl...
> In news: eL$l7Ep6DHA.1804@TK2MSFTNGP12.phx.gbl,
> Joaquin <jlopezh@earthlink.net> wrote:
> > COPY TO ( cOutput ) FOR STORE <> "CA" TYPE SDF
>
> How about testing first to see if there are any records that match the
> filter?
>
> SELECT COUNT(*) ;
> FROM MyTable ;
> INTO ARRAY laTemp ;
> WHERE Store <> "CA" ;
>
> IF laTemp[1] > 0
> COPY TO .....
> ENDIF
>
> --
> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> cindy.winegarden@mvps.org www.cindywinegarden.com
>
>
>



Re: UNABLE TO ERASE A FILE by Cindy

Cindy
Sun Feb 08 09:30:55 CST 2004

In news: %23gMWIa26DHA.1664@TK2MSFTNGP11.phx.gbl,
Joaquin <jlopezh@earthlink.net> wrote:
>>> COPY TO ( cOutput ) FOR STORE <> "CA" TYPE SDF
>>> IF no records meet the condition then FoxPro creates a file with zero
bytes.
>>> The problem that I'm having is that I cannot delete this file until I'm
>>> completing out of FoxPro.
>>> There has been a sharing violation - The source or destination file may
be
in use.

> I was just wondering why if
> anyone else had encouter this problem and would this be consider a
> bug in Foxpro.


I have played around with this and I can't duplicate your problem on my
WinXP machine. I recall posts here about file handles not being released by
the server OS and the solution was to change settings of the OS.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org www.cindywinegarden.com