61 lines
1.5 KiB
VB.net
61 lines
1.5 KiB
VB.net
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")
|
|
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
|
|
For Each fileItem As String In Directory.GetFiles(TempPath)
|
|
Logger.Debug("Deleting tempPath-file: {0} ...", fileItem)
|
|
File.Delete(fileItem)
|
|
Next
|
|
|
|
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
|