Forum Discussion

AJ's avatar
AJ
New Contributor III
3 years ago

Deleting multiple files from public folder

Hi  I am trying to delete files saved in public folder via business rule. Below BusinessRule.Extender works fine to delete the files from share folder. Dim configSettings As AppServerCon...
  • NickKroppe's avatar
    3 years ago

    Hi, 

     

    Below is a code example outlining how you may be able to delete files that exist in a given folder stored on the application database file structure.

     

    'get the folder you wish to delete files from in the application database
    Dim folder As XFFolderEx = BRApi.FileSystem.GetFolder(si, FileSystemLocation.ApplicationDatabase, "Documents/Public/SomeFolderName")
    'retrieve the files from the folder stored on the application database
    Dim fileList As List(Of XFFileInfoEx) = BRApi.FileSystem.GetFilesInFolder(si, FileSystemLocation.ApplicationDatabase, folder.XFFolder.FullName, XFFileType.All, Nothing)
    'loop through the files and delete them from the folder
    For Each varFile As XFFileInfoEx In fileList
    	brapi.FileSystem.DeleteFile(si, FileSystemLocation.ApplicationDatabase, varFile.XFFileInfo.FullName)
    Next

     

    Regards,

     

    Nick Kroppe