Imports System.IO Imports DigitalData.Modules.Logging Public Class Archive Private ReadOnly _LogConfig As LogConfig Private ReadOnly _Logger As Logger Public Sub New(LogConfig As LogConfig) _LogConfig = LogConfig _Logger = LogConfig.GetLogger() End Sub ''' ''' Sets a retention-period for a give file path by setting the file attributes LastAccessTime and ReadOnly ''' ''' ''' If greater than 0, sets this plus the current date as LastAccessTime ''' If true, sets ReadOnly Attribute Public Sub SetRetention(FilePath As String, RetentionTimeInDays As Integer, [ReadOnly] As Boolean) Try If RetentionTimeInDays > 0 Then _Logger.Info("Setting LastAccessTime for file [{0}]", FilePath) IO.File.SetLastAccessTime(FilePath, Date.Now.AddDays(RetentionTimeInDays)) End If Catch ex As Exception _Logger.Error(ex) End Try Try If [ReadOnly] Then _Logger.Info("Setting ReadOnly Attribute for file [{0}]", FilePath) Dim oAttributes = IO.File.GetAttributes(FilePath) Or FileAttributes.ReadOnly IO.File.SetAttributes(FilePath, oAttributes) End If Catch ex As Exception _Logger.Error(ex) End Try End Sub End Class