BenEppel
2 days agoNew Contributor III
Clearing Files in User Temp Folder as Non Admin
Good afternoon,
Does anybody know which security setting would allow a user to delete files from their Temp Folder?
I have tried changing the below System and Application Security Roles with no luck. Each time i get an error saying the User does not have permission to write to that folder.
Private Sub ClearUserTempFolder(ByVal si As SessionInfo)
Try
Dim userName As String = si.UserName.Replace(" ", "")
Dim location As FileSystemLocation = FileSystemLocation.ApplicationDatabase
Dim folderPath As String = $"Internal/Users/{userName}/Temp"
Dim fileTypeFilter As XFFileType = XFFileType.All
Dim contentFileExtensionFilters As List(Of String) = Nothing
' Get list of files
Dim objList As List(Of XFFileInfoEX) = BRApi.FileSystem.GetFilesInFolder(si, location, folderPath, fileTypeFilter, contentFileExtensionFilters)
If objList IsNot Nothing AndAlso objList.Count > 0 Then
For Each file In objList
Try
BRApi.FileSystem.DeleteFile(si, location, file.XFFileInfo.FullName)
BRApi.ErrorLog.LogMessage(si, $"Deleted file: {file.XFFileInfo.FullName}")
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
Next
Else
BRApi.ErrorLog.LogMessage(si, $"No files to delete in {folderPath}")
End If
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Sub