Fix deleting original file error by setting file attributes to normal
This commit is contained in:
@@ -69,7 +69,7 @@ Public Class frmIndex
|
||||
End If
|
||||
|
||||
_Logger.Warn(oMessage)
|
||||
_Logger.Error(Exception.Message)
|
||||
_Logger.Error(Exception)
|
||||
|
||||
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
|
||||
End Sub
|
||||
@@ -84,6 +84,28 @@ Public Class frmIndex
|
||||
Localizer.Active = New LookupGridLocalizer()
|
||||
End Sub
|
||||
|
||||
Public Sub CloseViewer()
|
||||
If DocumentViewer1 Is Nothing Then
|
||||
LOGGER.Warn("DocumentViewer is already closed!")
|
||||
End If
|
||||
|
||||
Try
|
||||
LOGGER.Debug("Calling CloseDocument on Viewer")
|
||||
DocumentViewer1.CloseDocument()
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Calling CloseDocument on Viewer FAILED")
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
|
||||
Try
|
||||
LOGGER.Debug("Calling Done on Viewer")
|
||||
DocumentViewer1?.Done()
|
||||
Catch ex As Exception
|
||||
LOGGER.Warn("Calling Done on Viewer FAILED")
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub DisposeViewer()
|
||||
DocumentViewer1.Dispose()
|
||||
End Sub
|
||||
@@ -1496,9 +1518,8 @@ Public Class frmIndex
|
||||
|
||||
Try
|
||||
INDEXING_ACTIVE = False
|
||||
CloseViewer()
|
||||
|
||||
DocumentViewer1.CloseDocument()
|
||||
DocumentViewer1.Done()
|
||||
ClassWindowLocation.SaveFormLocationSize(Me)
|
||||
My.Settings.Save()
|
||||
Catch ex As Exception
|
||||
@@ -1515,8 +1536,7 @@ Public Class frmIndex
|
||||
Try
|
||||
INDEXING_ACTIVE = False
|
||||
|
||||
DocumentViewer1.CloseDocument()
|
||||
DocumentViewer1.Done()
|
||||
CloseViewer()
|
||||
ClassWindowLocation.SaveFormLocationSize(Me)
|
||||
My.Settings.Save()
|
||||
Catch ex As Exception
|
||||
@@ -1527,6 +1547,9 @@ Public Class frmIndex
|
||||
INDEXING_ACTIVE = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub frmIndex_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
' Abbruchzähler zurücksetzen
|
||||
CancelAttempts = 0
|
||||
@@ -2249,7 +2272,7 @@ Public Class frmIndex
|
||||
|
||||
Sub PreviewFile()
|
||||
Try
|
||||
DocumentViewer1.LoadFile(CURRENT_WORKFILE)
|
||||
'DocumentViewer1.LoadFile(CURRENT_WORKFILE)
|
||||
Catch ex As Exception
|
||||
ShowErrorMessage(ex, "PreviewFile")
|
||||
End Try
|
||||
@@ -2290,11 +2313,6 @@ Public Class frmIndex
|
||||
|
||||
'Den Zielnamen zusammenbauen
|
||||
If Name_Generieren() = True Then
|
||||
'Dokumentenviewer ausblenden um keinen Zugriffsfehler zu produzieren
|
||||
DocumentViewer1.Done()
|
||||
DocumentViewer1.CloseDocument()
|
||||
|
||||
_Logger.Debug(" ...Viewer geschlossen")
|
||||
'Die Datei verschieben
|
||||
If Move_File2_Target() = True Then
|
||||
_Logger.Debug(" ...Move_File2_Target durchlaufen")
|
||||
@@ -2303,10 +2321,15 @@ Public Class frmIndex
|
||||
Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & CURRENT_WORKFILE_GUID
|
||||
DATABASE_ECM.ExecuteNonQuery(oDEL)
|
||||
|
||||
'Dokumentenviewer ausblenden um keinen Zugriffsfehler zu produzieren
|
||||
CloseViewer()
|
||||
_Logger.Debug(" ...Viewer geschlossen")
|
||||
|
||||
If CURR_DELETE_ORIGIN = True Then
|
||||
_Logger.Info("Datei [" & CURRENT_WORKFILE & "] wird gelöscht.")
|
||||
Try
|
||||
System.IO.File.Delete(CURRENT_WORKFILE)
|
||||
File.SetAttributes(CURRENT_WORKFILE, FileAttributes.Normal)
|
||||
File.Delete(CURRENT_WORKFILE)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
@@ -2777,8 +2800,7 @@ Public Class frmIndex
|
||||
MsgBox("All files were successfully processed through Multiindexing", MsgBoxStyle.Information, "Success")
|
||||
End If
|
||||
|
||||
DocumentViewer1.CloseDocument()
|
||||
DocumentViewer1.Done()
|
||||
CloseViewer()
|
||||
|
||||
CancelAttempts = 2
|
||||
Me.Close()
|
||||
@@ -2796,8 +2818,7 @@ Public Class frmIndex
|
||||
End If
|
||||
End If
|
||||
|
||||
DocumentViewer1.CloseDocument()
|
||||
DocumentViewer1.Done()
|
||||
CloseViewer()
|
||||
|
||||
CancelAttempts = 2
|
||||
Me.Close()
|
||||
@@ -2852,7 +2873,18 @@ Public Class frmIndex
|
||||
CONFIG.Save()
|
||||
End Sub
|
||||
|
||||
Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click
|
||||
|
||||
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
||||
Try
|
||||
MsgBox($"Deleting [{CURRENT_WORKFILE}]", MsgBoxStyle.Information, Text)
|
||||
|
||||
File.SetAttributes(CURRENT_WORKFILE, FileAttributes.Normal)
|
||||
File.Delete(CURRENT_WORKFILE)
|
||||
|
||||
'IO.File.Delete(CURRENT_WORKFILE)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user