Thanks to all who responded. My use at this point is to create unique filenames on a server in a bulletproof way. I rejected the approach of testing for file existence before creation because multiple programs running create a (very slight) chance that two instances will attempt to create a file with the same name at the same time.
It is possible to reliably create the file by setting safety off but this does not protect against a second program's using the same name and overwriting the information written by the first. I posted the question partly because the Try/Catch approach is new to me. It looks great but it doesn't seem to completely handle the first thing I tried to use it for. Tracy says the behavior is by design. My question is why is it designed this way and is there some logic that will define what the other commands or conditions are that will not be trapped by Catch? I think I can achieve what I need by looping FCREATE(<UniqueName>) until success. At that point I will have the name of a file I can safely overwrite by setting safety off. The API approach is something I would like to know more about. Where does one get a list of what is available? Thanks, Joe On Tuesday, July 03, 2007 9:04 AM, Kevin Cully wrote: > >Date: Tue, 03 Jul 2007 09:04:00 -0400 >From: Kevin Cully >To: [EMAIL PROTECTED] >Subject: Re: Try/Catch handling of Copy File errors > >Can you do a FILE() before attempting to copy the file? > >lcTargetFile = "c:\test\target.dbf" >IF FILE(lcTargetFile) > && Log that the file already exists >ELSE > TRY > COPY FILE (lcSourceFile) TO (lcTargetFile) > CATCH > && Log problem of copying file. > ENDTRY >ENDIF > >I've been using the COPYFILE from the WIN32API because it is faster than >the VFP based COPY FILE command. It might be worth looking into. I'm a > WebConnect customer so they have that in the wwAPI class. > >HTH. > >-Kevin >CULLY Technologies, LLC > >Sponsor of FoxForward 2007 >foxforward.net > > >Joe Yoder wrote: >> I need to copy a file from one directory to another. I use the COPY FILE >> <SourceFile> TO <DestinationName> inside the Try/Catch structure. >> >> When <SourceFile> does not exist, Catch gets control and all is well. >> >> When <DestinationName> does not exist, Catch gets control and all is well. >> >> When <DestinationName> already exists, I get an Interactive Message Box >> reporting that fact and asking what to do. Catch does not get control so >> there is a problem as this applications needs to run unattended! >> >> Does anyone know whether this behavior is by design and if so - why? Any >> workarounds? >> >> Thanks - Joe >> >> >> >> --- StripMime Report -- processed MIME parts --- >> multipart/alternative >> text/plain (text body -- kept) >> text/html >> --- >> [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

