Forum Discussion
- Gidon_AlbertContributor II
You can create a "File Explorer" button on a Dashboard that opens the file share dialog box:
After the dialog opens, you can navigate to the folder where your file is and select a file you want to delete. When you hit the "Select File" button in the dialog, the file name passes to the bound parameter, which passes as an args.NameValueParis to the BR, which deletes the file:
Public Function Delete_Selected_File(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardExtenderArgs) As Object
'------------------------------------------------------------------------------------------------------------
'Reference Code: DeleteFile
'
'Description: Select and delete a file
'
'
'Created By: Gidon Albert
'Date Created: 09-23-2021
'------------------------------------------------------------------------------------------------------------
TryDim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
Dim archiveFolder As String = FileShareFolderHelper.GetApplicationFolderForApp(si, True, configSettings.FileShareRootFolder, si.AppToken.AppName)
Dim archiveFolderFields As List(Of String) = StringHelper.SplitString(archiveFolder, "\", StageConstants.ParserDefaults.DefaultQuoteCharacter)
Dim targetFile As String = args.NameValuePairs.XFGetValue("Selected File", "")
'********* debug info *********
If debugSwitch = True Then brapi.ErrorLog.LogMessage(si,"Delete Selected File: " & vbCrLf &
"archiveFolder: " & archiveFolder & vbCrLf &
"targetFile: " & targetFile)
'******************************Dim TFF As List(Of String) = StringHelper.SplitString(targetFile, "/", StageConstants.ParserDefaults.DefaultQuoteCharacter)
targetFile = archiveFolder & "\" & TFF.Item(2) & "\" & TFF.Item(3) & "\" & TFF.Item(4) & "\" & TFF.Item(5) & "\" & TFF.Item(6)
'Delete the file
'Verify if file exists prior to deletion
If system.IO.File.Exists(targetFile) Then
'********* debug info *********
If debugSwitch = True Then brapi.ErrorLog.LogMessage(si,"Delete Selected File: " & vbCrLf &
"targetFile: " & targetFile)
'******************************
System.IO.File.Delete(targetFile)
End If
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function- WernerNContributor
Thank you for the 'File Explorer Button' idea. Love it as I can nicely integrate it into an admin dashboard.
Now i just wish that OneStream would introduce the capability for multiple selection. Not only for deleting a file.- NickKroppeContributor
Give the MarketPlace solution "File Explorer Manager" a try. It's a recent solution that mirrors the platform file explorer and adds some ease of use functionality such as multiselecting files for download, delete, copy, move, as well as presenting timestamps in the user's time zone.
- NickKroppeContributor
Hi,
As Lee mentioned, if your OneStream environment is managed by the OneStream Customer Support team you may open a ticket and list the files/folders you wish to delete from the fileshare. This is currently the recommended and easiest approach.
If you are comfortable with business rules, you do have the ability to take matters into your own hands and create a custom rule to forcefully delete files/folders from the fileshare. I will post two basic snippets of how to delete a file and folder from the fileshare. Please keep in mind that the deleted files/folders will not be recoverable and performing these actions should be tested in a Development application first - if you take this approach you are doing this at your own risk.
Lastly, as a general FYI - there are multiple enhancements logged relating to this and I suspect/hope that at some point in the future deleting files/folders from the fileshare may be possible with standard platform or marketplace solution functionality.
'************************************************************************ 'Example of deleting a file from the fileshare '************************************************************************ 'declare the filepath for the file on the fileshare you wish to delete Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si) Dim sourceFilePath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.FileShareRootFolder, si.AppName) & "\20211220\SomeFileName.csv" 'delete the file from the machine (warning, the file cannot be recovered) File.Delete(sourceFilePath) '********************************************************************************* 'Example of deleting a folder and its subdirectories and files from the fileshare '********************************************************************************* 'declare the folder path for the folder on the fileshare you wish to delete Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si) Dim sourceFolderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.FileShareRootFolder, si.AppName) & "\SomeFileShareFolderName" 'delete the folder and all it's subdirectories and files in the directory (warning, the folder and nested directories/files cannot be recovered) Directory.Delete(sourceFolderPath, True)
Nick Kroppe
OneStream Software
- LeeBContributor II
Hi Mark,
It is not currently possible within the UI as it has to be done on the machine the application is hosted on. Contact OS Support for further assistance.
Regards,
Lee - MarkHoughtonContributor
Thanks Nick for that code segment. The file transfer was to/from 2 dev environments anyway, so no risk to the live. Cheers.
- MarkHoughtonContributor
Thank you very much for that comprehensive solution. It will be very useful indeed.
Mark
Related Content
- 10 months ago