Forum Discussion
PhinaDanM
1 year agoNew Contributor
FileShare Harvest Folder view and deletion
Hello All,
Our initial setup had everything copying data files to Application/Batch/Harvest folder. There has been multiple years of files stored in this location making it unable to open. I am trying to create something to pull the files and if folders are created to delete the stored files. I am uable to open the path and the clean up business rule fails to run due to the size. I spoke with some developers at Nashville Splash and am reaching out on here as well.
Sounds like the file structure is too large for the UI to render, and your best bet is to use BRs to examine and delete the unused files.
I would start by trying to get a handle on how many files actually exist in the file share.
Dim sb As New StringBuilder(String.Empty) Dim batch = BRApi.FileSystem.GetFileShareFolder(si, FileShareFolderTypes.Batch, Nothing) Dim directories = Directory.GetDirectories(batch) sb.appendLine(directories.Count().ToString) For Each dir As String In directories sb.appendline("DIRECTORY: " + dir + " Contains " + Directory.GetFiles(dir).Count().ToString + " files") Next brapi.ErrorLog.LogMessage(si, sb.tostring())This code snippet should let you see how many directories and files exist.
Once you have a list of all of the directories, you can then get a list of all of the files contained in the directory using the Directory.GetFiles command. Then you can loop through the file names and use File.Delete to delete the individual files.
Once the Directory contains no files, you can then use Directory.Delete to remove the old directories.
*BE CAREFUL USING FILE.DELETE and DIRECOTRY.DELETE
You could accidentally remove the Batch or Harvest directory, so make sure you know exactly what will be deleted before executing.
3 Replies
- atalecki
OneStream Employee
Sounds like the file structure is too large for the UI to render, and your best bet is to use BRs to examine and delete the unused files.
I would start by trying to get a handle on how many files actually exist in the file share.
Dim sb As New StringBuilder(String.Empty) Dim batch = BRApi.FileSystem.GetFileShareFolder(si, FileShareFolderTypes.Batch, Nothing) Dim directories = Directory.GetDirectories(batch) sb.appendLine(directories.Count().ToString) For Each dir As String In directories sb.appendline("DIRECTORY: " + dir + " Contains " + Directory.GetFiles(dir).Count().ToString + " files") Next brapi.ErrorLog.LogMessage(si, sb.tostring())This code snippet should let you see how many directories and files exist.
Once you have a list of all of the directories, you can then get a list of all of the files contained in the directory using the Directory.GetFiles command. Then you can loop through the file names and use File.Delete to delete the individual files.
Once the Directory contains no files, you can then use Directory.Delete to remove the old directories.
*BE CAREFUL USING FILE.DELETE and DIRECOTRY.DELETE
You could accidentally remove the Batch or Harvest directory, so make sure you know exactly what will be deleted before executing.
- MarcusHValued Contributor
Have a look at the MarketPlace Solution File Explorer Manager. That presents the contents of the FileShare (including the Batch folders) in a dashboard. You can then delete files and folders.
- PhinaDanMNew Contributor
Thank you both, the directory count worked perfectly and now can use the delete or File Explorer change manager.
Related Content
- 2 years ago
- 2 months ago
- 1 month ago