Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A strange 'File in Use by Another' error
Message
De
20/05/1999 09:42:34
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/05/1999 08:45:40
David Abraham
David Abraham & Associates, Inc.
New York City, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00220768
Message ID:
00220813
Vues:
27
>ndxname = 'X' + SYS(3)
>INDEX ON [fldname] TO &ndxname
>
>Look familiar? This is how we FP'ers have created a new filename since the beginning of time. And I am having a 'File in use by another' error come up on my client's app, sometimes. Actually not sometimes, but always on my client's PC's which run Win98, the error does not happen on the one PC in the store that runs Win95. However, it does not occur on my development PC, which runs Win98 too. It does NOT make sense to me that this is the operative difference but I have nothing else to go on. Any ideas?
Fox itself doesn't guarentee a unique filename with sys(3) (especially on fast computers) and offer sys(2015) instead (on a particular machine different even if called in the same millisecond but of course might be same when called on more then one computers).
Moreover a do while loop could provide one unused :
function GetFreeFileName
lcFileName = "X"+sys(2015) 
handle = fcreate(lcFileName)
do while handle < 0
 lcFileName = "X"+sys(2015) 
 handle = fcreate(lcFileName)
enddo
=fclose(handle)
return lcFileName
Also using local path for temporary files would not only prevent collision but improve performance as well.
For indexes instead of new files, using tags would be more effective :
lcTagName = "T"+substr(sys(2015),2) && Tagnames use 10 chars
INDEX ON expression Tag (lcTagName)
* Do whatever with tag
delete tag (lcTagName)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform