Imports System.IO Imports DigitalData.Modules.Base Imports DigitalData.Modules.Logging Public Class TempFiles Inherits BaseClass Public Property _TempPath As String Public Sub New(pLogConfig As LogConfig) MyBase.New(pLogConfig) Dim oTempDirectoryPath = Path.GetTempPath() _TempPath = Path.Combine(oTempDirectoryPath, "EnvelopeGenerator") If Not Directory.Exists(_TempPath) Then Directory.CreateDirectory(_TempPath) End If End Sub Public Function Create() As Boolean Try If Directory.Exists(_TempPath) = False Then Directory.CreateDirectory(_TempPath) Else CleanUpFiles() End If Return True Catch ex As Exception Logger.Error(ex) Return False End Try End Function Private Function CleanUpFiles() As Boolean Try If Directory.Exists(_TempPath) Then For Each fileItem As String In Directory.GetFiles(_TempPath) Logger.Debug("Deleting tempPath-file: {0} ...", fileItem) File.Delete(fileItem) Next End If Return True Catch ex As Exception Logger.Error(ex) Return False End Try End Function Public Function CleanUp() As Boolean Try Logger.Debug("Deleting tempPath-Data: {0} ...", _TempPath) Directory.Delete(_TempPath, True) Return True Catch ex As Exception Logger.Error(ex) Return False End Try End Function End Class