/ Forums / Advansys Formativ / Formativ Creator / how can I delete all files in a folder

  • Creator
    Topic
  • #3589
    hugo13
    Participant

    Hi

    I want to delete all files in one folder without deleting the files in the subfolder

    1. I tried

    Utilities.FileSystem.DeleteFileOnDisk ("C:formativ*.*")

    but this will delete all subfolders too
    an interesting call: Utilities.FileSystem.DeleteFileOnDisk (“E:*.*”) Razz
    2.

        Set fs = CreateObject("Scripting.FileSystemObject")
    fs.DeleteFile "C:formativ*.*", True

    but this only runs in the admin-area (creator) but not in the runtime environment; there I have to use “C:formativeLETTER*.*”

    maybe there is a switch or an other call

    thanks
    rainer

  • Author
    Replies
  • #5544
    Support 3
    Participant

    Iterate through all files in the target folder and delete the file. See below the sample code.

     set oFSO = Utilities.FileSystem
     set oIterator = oFSO.FileIterator
     oIterator.FileSpec = "c:temptest*.*"
     oIterator.load()
    
     for x = 0 to oIterator.Files.Count -1
       oFSO.DeleteFileOnDisk(oIterator.Files.strings(x))
     next
    
     set oFSO = nothing
    

    Hope this helps.

    Regards,
    Advansys Support

    #5545
    hugo13
    Participant

    thanks for your answer; it works

    rainer

    #5543
    Support 2
    Moderator

    Great, thanks for the feedback!

    Regards,

    Advansys Support

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.