fix file access error and illegal path error

This commit is contained in:
Jonathan Jenne
2022-01-25 13:24:28 +01:00
parent a35d77d51f
commit a921072556
6 changed files with 89 additions and 77 deletions

View File

@@ -6,21 +6,26 @@ Imports DigitalData.Modules.Language
Imports Limilabs.Mail
Public Class ClassFilehandle
Public Shared Function Decide_FileHandle(pFilepath As String, pHandletype As String)
Public Shared Function Decide_FileHandle(pFilepath As String, pHandletype As String) As Boolean
Try
'TODO: Before doing anything, clean the filename
Dim oFilename = IO.Path.GetFileName(pFilepath)
Dim oCleanFileName = Utils.RemoveInvalidCharacters(oFilename)
Dim oTempDirectory = IO.Path.GetTempPath()
Dim oTempFilePath = IO.Path.Combine(oTempDirectory, oCleanFileName)
''TODO: Before doing anything, clean the filename
'Dim oFilename = IO.Path.GetFileName(pFilepath)
'Dim oCleanFileName = Utils.RemoveInvalidCharacters(oFilename)
'Dim oTempDirectory = IO.Path.GetTempPath()
'Dim oTempFilePath = IO.Path.Combine(oTempDirectory, oCleanFileName)
Try
TEMP_FILES.Add(oTempFilePath)
IO.File.Copy(pFilepath, oTempFilePath, True)
Catch ex As Exception
LOGGER.Error(ex)
Throw ex
End Try
'Try
' TEMP_FILES.Add(oTempFilePath)
' LOGGER.Debug("Copying file")
' LOGGER.Debug(pFilepath)
' LOGGER.Debug(oTempFilePath)
' IO.File.Copy(pFilepath, oTempFilePath, True)
'Catch ex As Exception
' LOGGER.Error(ex)
' Throw ex
'End Try
Dim oTempFilePath = pFilepath
If oTempFilePath.ToUpper.EndsWith(".MSG") Or oTempFilePath.ToUpper.EndsWith(".EML") Then
CURRENT_MESSAGEID = ""