Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Erase gives File Access Denied
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00081988
Message ID:
00082360
Vues:
26
>>>What can be the reasons why the Visual FoxPro 5 Erase command will generate a File Access Denied? I have a process which is using the Erase command to remove some files. That process is executed several times per day. However, a few times per week, I have a log which says File Access Denied.
>>
>>Apart from the usual reasons, you don't have permission, the file is read only etc.
>>
>>If it happens on a temporary file its likely that whatever network or OS has the file open 'believes' that a different process has the file already open. If you are absolutely sure that you are always closing the files before opening them check with the Network OS that there isn't some buffering problem. If its that you are creating temporaries, closing then deleting them try delaying deleting the files after closing them for as long as possible.
>>
>>You might also make sure that you haven't got a different data session running.
>>
>>Simon
>
>Hi Michel,
>
>The "different datasession" is the one that foils me usually. I'll create a cursor in one private datasession, copy it to an independent dbf, open up another form which has it's own private datasession and find that neither form will be able to erase the file I created. I think that both data sessions seem to think that it is somehow connected to it so ERASE fails.
>In addition to the answers already provided, you may also hit the 'sticky' situation where you are not told that the file access is denied, but instead the Win 32 OS gives a nasty message, which VFP won't ever see. To avoid this, I began using the following code to 'ERASE' files:
.
.
.
* build an array of 'junk file names' called 'lafilenames'
.
.
m.lnFileNum = Fopen( lafilenames[m.lnCleanTempDir,01], 2 ) && 11/24/97 -- Read / Write ( simulates exclusive )
*
* 09/12/97 -- if we can FOPEN() and FCLOSE()
* we "own" it and can safely erase it...
*
if fclose( m.lnFileNum )
*
* Eliminate left over temporary files
*
if file( laFileNames[m.lnCleanTempDir,01] )
*
* 11/24/97 -- got error message that file did not exist...
*
m.lcCommand = ;
"Erase " + ;
laFileNames[m.lnCleanTempDir,01]
&lcCommand

endif

endif

This will not give any error messages; however, it you require that the file absolutely, positively be erased, you could bring up a modal dialog to the user on the failure to FCLOSE() the file and demand that they locate who / what is withholding access. The files I have to erase are mostly cursors, semaphores, and temporary text files -- if I don't erase them now, I will get them soon. Hope this helps.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform