@@ -6648,21 +6648,51 @@ Public Class ProgressPanel
66486648 Dim FileLength As Integer = 0
66496649 FileLength = New FileInfo(LogFile).Length
66506650 DynaLog.LogMessage( "Size of log file in bytes: " & FileLength)
6651- If FileLength <> 0 Then
6652- File.AppendAllText(LogFile, CrLf & "==================== DISMTools Log Window Contents (" & DateTime.Now.ToString() & ") ====================" , ASCII)
6653- Else
6654- File.AppendAllText(LogFile, "======================== DISMTools Log File ========================" & CrLf &
6655- "This is an automatically generated log file created by DISMTools." & CrLf &
6656- "This file can be viewed at any time to view successful and/or" & CrLf &
6657- "failed tasks." & CrLf & CrLf &
6658- "This log file is updated every time an operation is performed." & CrLf &
6659- "However, it does not contain the actual DISM log file, which is" & CrLf &
6660- "also automatically generated each time DISM is run from this" & CrLf &
6661- "program. These log files are named: " & CrLf &
6662- " " & Quote & "DISMTools-<date/time>.log" & Quote & " " & CrLf &
6663- "====================================================================" , ASCII)
6664- End If
6665- File.AppendAllText(LogFile, CrLf & LogView.Text, ASCII)
6651+ Try
6652+ If FileLength <> 0 Then
6653+ File.AppendAllText(LogFile, CrLf & "==================== DISMTools Log Window Contents (" & DateTime.Now.ToString() & ") ====================" , ASCII)
6654+ Else
6655+ File.AppendAllText(LogFile, "======================== DISMTools Log File ========================" & CrLf &
6656+ "This is an automatically generated log file created by DISMTools." & CrLf &
6657+ "This file can be viewed at any time to view successful and/or" & CrLf &
6658+ "failed tasks." & CrLf & CrLf &
6659+ "This log file is updated every time an operation is performed." & CrLf &
6660+ "However, it does not contain the actual DISM log file, which is" & CrLf &
6661+ "also automatically generated each time DISM is run from this" & CrLf &
6662+ "program. These log files are named: " & CrLf &
6663+ " " & Quote & "DISMTools-<date/time>.log" & Quote & " " & CrLf &
6664+ "====================================================================" , ASCII)
6665+ End If
6666+ File.AppendAllText(LogFile, CrLf & LogView.Text, ASCII)
6667+ Catch ex As Exception
6668+ DynaLog.LogMessage( "Could not log this operation. Error message: " & ex.Message)
6669+ End Try
6670+ End Sub
6671+
6672+ Sub SaveDismOutput(OutputFile As String )
6673+ DynaLog.LogMessage( "Saving DISM output to a file..." )
6674+ DynaLog.LogMessage( "- Log destination: " & Quote & OutputFile & Quote)
6675+ If String .IsNullOrEmpty(DISM_LogView.RichTextBox1.Text) Then
6676+ DynaLog.LogMessage( "There is no content to save." )
6677+ Exit Sub
6678+ End If
6679+ Try
6680+ If Not File.Exists(OutputFile) Then
6681+ DynaLog.LogMessage( "Attempting to create output file..." )
6682+ ' Create file
6683+ Try
6684+ File.WriteAllText(OutputFile, String .Empty)
6685+ Catch ex As Exception
6686+ DynaLog.LogMessage( "Could not create log file. Error message: " & ex.Message)
6687+ LogView.AppendText(CrLf &
6688+ "Warning: the contents of the log window could not be saved to the log file. Reason: " & ex.Message)
6689+ Exit Sub
6690+ End Try
6691+ End If
6692+ File.AppendAllText(OutputFile, DISM_LogView.RichTextBox1.Text, ASCII)
6693+ Catch ex As Exception
6694+ DynaLog.LogMessage( "Could not log this operation. Error message: " & ex.Message)
6695+ End Try
66666696 End Sub
66676697
66686698 Private Sub ProgressBW_RunWorkerCompleted(sender As Object , e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles ProgressBW.RunWorkerCompleted
@@ -6674,6 +6704,7 @@ Public Class ProgressPanel
66746704 " dism /mount-image /imagefile:" & Quote & imgIndexDeletionSourceImg & Quote & " /index:<preferred index> /mountdir:<preferred mountpoint>" )
66756705 DynaLog.LogMessage( "Saving operation logs..." )
66766706 SaveLog(Application.StartupPath & "\logs\DISMTools.log" )
6707+ SaveDismOutput(Application.StartupPath & "\logs\DISM_Output_" & Date .Now.ToString( "yy-MM-dd-HH-mm-ss" ) & ".log" )
66776708 Try
66786709 CurrentPB.Value = 100
66796710 Catch ex As Exception
@@ -7106,6 +7137,7 @@ Public Class ProgressPanel
71067137 End Select
71077138 MainForm.StatusStrip.BackColor = CurrentTheme.AccentColors( 1 )
71087139 SaveLog(Application.StartupPath & "\logs\DISMTools.log" )
7140+ SaveDismOutput(Application.StartupPath & "\logs\DISM_Output_" & Date .Now.ToString( "yy-MM-dd-HH-mm-ss" ) & ".log" )
71097141 End If
71107142 End Sub
71117143
0 commit comments