Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting Files in a Temp Folder!!
Message
 
À
13/09/2001 17:06:29
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00555484
Message ID:
00556662
Vues:
21
>>>I have Created a temp folder called TempFox that will hold various files genereated from my Fox Program. I am using a Kickoff program to do various items before the Fox program Launches. One of these tasks is to Clean Out the TempFox folder. I can use the object.delete methods or the KILL command but if i file is still open an error will occur. Fox has a function called ADIR() which returns the number of enties in an array created by the function or supplied to the function. The array holds information about all files and folders within A folder( or in this case the Tempfox folder). I need to delete files sequentially in order to get All files Not OPEN or being used.!! Is there a VB function that is equivalent to this? or maybe a work around. Trying to avoid using API function calls if neccessary!!!
>>
>>Try this:
>>
>>dim fso as FileSystemObject
>>dim oFile as File
>>dim oFiles as Files
>>dim oFolder as Folder
>>
>>on error resume next
>>' Assures that it won't error out on opened or used files.
>>set fso = new FileSystemObject
>>set oFolder=fso.getfolder("c:\tempfox")
>>for each oFile in oFolder
>>    oFile.Delete
>>next
>>
>>
>>HTH
>
>Igor,
> The Method Seems Good but for oFile it returns - Nothing- . It seems to not want to Get the files in the folder. any suggestions? i copied and pasted right from the previous code!! and added the reference to Ms script.

Sorry,

Please correct the code:
for each oFile in <font color="red">oFolder.Files</font>
    oFile.Delete
next
HTH
Igor Gelin
Database Developer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform