Skip to content

Commit

Permalink
Fixed crash if couldn't rename the move file.
Browse files Browse the repository at this point in the history
Fixed adding ".fpt_part" files to the list of files to move.
  • Loading branch information
Ron authored and Ron committed Nov 1, 2023
1 parent d47b363 commit d095c0d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
80 changes: 42 additions & 38 deletions Form1.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Option Strict On
'
' Github - push/pull and Commit (box pops up on the right) prior to releasing
' If using an old tag on release on Github, it will pull old soucre code
' Make sure code has updated prior to releasing.
'

Option Strict On
Option Explicit On


Expand Down Expand Up @@ -1061,7 +1067,7 @@ Public Class Form1
Catch ex As Exception

'MessageBox.Show(String.Format("Error in DriveFreeSpace: {0}", ex.Message))
ExceptionThrown("DriveFreeSpace", String.Format("{0}" & ex.Message))
ExceptionThrown("DriveFreeSpace", String.Format("{0}", ex.Message))

Return 0
End Try
Expand Down Expand Up @@ -1128,11 +1134,19 @@ Public Class Form1
ListBox_Plots2Move.Items.Clear()
ListBox_SizeOfPlots.Items.Clear()

Dim Len = PlotType.Length + 1 'we get the length + 1 to allow for the .


For Each fi In aryFi

strFileSize = (Math.Round(fi.Length / 1024 / 1024 / 1024, 2)).ToString()
ListBox_Plots2Move.Items.Add(fi.FullName)
ListBox_SizeOfPlots.Items.Add(strFileSize)
'had to add validation, as for some reason on some computers it would pick .fpt_part, which is the temp file.

If Strings.Right(fi.FullName, Len) = "." & PlotType Then
strFileSize = (Math.Round(fi.Length / 1024 / 1024 / 1024, 2)).ToString()
ListBox_Plots2Move.Items.Add(fi.FullName)
ListBox_SizeOfPlots.Items.Add(strFileSize)
End If


Next

Expand All @@ -1142,7 +1156,7 @@ Public Class Form1
Catch ex As Exception

'MessageBox.Show(String.Format("Error in GetListofPlots: {0}", ex.Message))
ExceptionThrown("GetListofPlots", String.Format("{0}" & ex.Message))
ExceptionThrown("GetListofPlots", String.Format("{0}", ex.Message))

End Try

Expand Down Expand Up @@ -1270,26 +1284,10 @@ Public Class Form1
Private Sub Btn_ClearErrors_Click(sender As Object, e As EventArgs) Handles Btn_ClearErrors.Click

ErrorGridView.Rows.Clear()
ErrorGridView.Columns.Clear()
TabCtrl.TabPages(2).Text = "Error Exceptions (0)"

End Sub

Private Sub ListBox_Errors_DoubleClick(sender As Object, e As EventArgs)

'For x = 0 To ListBox_Errors.Items.Count - 1
'If ListBox_Errors.SelectedItem Then
' Next

' Dim SelectedError As String = ListBox_Errors.SelectedItems.ToString
' My.Computer.Clipboard.SetText(clip)

' MsgBox()

End Sub




Private Sub UpdateMovesList()

Expand Down Expand Up @@ -1488,10 +1486,6 @@ Public Class Form1

End If

ListBox_PlotsBeingMoved.Items.RemoveAt(DriveNumber - 1)
ListBox_PlotsBeingMoved.Items.Insert(DriveNumber - 1, "Drive " & DriveNumber.ToString & " (" & Nickname(DriveNumber) & ") busy moving " & PlotFullPathName & " to " & Destination(DriveNumber))
DriveBusy(DriveNumber) = True

'Now we move the plot

Dim NewPlotName As String
Expand All @@ -1508,16 +1502,28 @@ Public Class Form1

NewPlotName = PlotName & ".mov" & DriveNumberText

My.Computer.FileSystem.RenameFile(PlotFullPathName, NewPlotName)
Try

My.Computer.FileSystem.RenameFile(PlotFullPathName, NewPlotName)

ListBox_PlotsBeingMoved.Items.RemoveAt(DriveNumber - 1)
ListBox_PlotsBeingMoved.Items.Insert(DriveNumber - 1, "Drive " & DriveNumber.ToString & " (" & Nickname(DriveNumber) & ") busy moving " & PlotFullPathName & " to " & Destination(DriveNumber))
DriveBusy(DriveNumber) = True

NewPlotName = PlotFullPathName & ".mov" & DriveNumberText
NewPlotName = PlotFullPathName & ".mov" & DriveNumberText


FileMoving(DriveNumber) = NewPlotName 'This will be monitored to know when the move has finished - deleted
FileMoving(DriveNumber) = NewPlotName 'This will be monitored to know when the move has finished - deleted

Process.Start(My.Application.Info.DirectoryPath + "\PlotMove.exe", Destination(DriveNumber) & "/" & Nickname(DriveNumber) & "/" & NewPlotName)
Process.Start(My.Application.Info.DirectoryPath + "\PlotMove.exe", Destination(DriveNumber) & "/" & Nickname(DriveNumber) & "/" & NewPlotName)

LastDriveMovedTo = DriveNumber
LastDriveMovedTo = DriveNumber

Catch ex As Exception

ExceptionThrown("MoveNextPlot", String.Format("{0}", ex.Message))

End Try

End If

Expand Down Expand Up @@ -1551,11 +1557,9 @@ Public Class Form1

Dim di As New IO.DirectoryInfo(PlotSourceFolder)
Dim MoveFilesAry As IO.FileInfo() = di.GetFiles("*.mov*")
Dim PlotFilesAry As IO.FileInfo() = di.GetFiles("*." & PlotType)

ActiveMoves = MoveFilesAry.Count
Dim PlotsWaitng = PlotFilesAry.Count

Dim PlotsWaitng = ListBox_Plots2Move.Items.Count
Dim MyStatus As String
Dim PlotsWaitingStr As String

Expand All @@ -1580,15 +1584,15 @@ Public Class Form1

'we check if all drives are full and or not valid, thus no where to move plots to

For a = 0 To 9
For a = 0 To (DriveSlots - 1)

Mytext = ListBox_PlotsBeingMoved.Items(a).ToString
If Mytext.Contains("full") Then count += 1
If Mytext.Contains("location") Then count += 1

Next

If count = 10 Then MyStatus = "Drives are either full or not setup."
If count = DriveSlots Then MyStatus = "Drives are either full or not setup."

ElseIf ActiveMoves > 1 Then
MyStatus = "There are " & ActiveMoves.ToString & " plots being moved."
Expand All @@ -1609,7 +1613,7 @@ Public Class Form1
Catch ex As Exception

'MessageBox.Show(String.Format("Error in UpdateStatus: {0}", ex.Message))
ExceptionThrown("UpdateStatus", String.Format("{0}" & ex.Message))
ExceptionThrown("UpdateStatus", String.Format("{0}", ex.Message))

End Try

Expand Down Expand Up @@ -1759,7 +1763,7 @@ Public Class Form1
Catch ex As Exception
' Handle any exceptions that may occur, or not as the case may be!
'MessageBox.Show(String.Format("Error in GetFolderSize: {0}", ex.Message))
ExceptionThrown("GetFolderSize", String.Format("{0}" & ex.Message))
ExceptionThrown("GetFolderSize", String.Format("{0}", ex.Message))
End Try

End If
Expand Down
4 changes: 2 additions & 2 deletions My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.13.0.0")>
<Assembly: AssemblyFileVersion("1.13.0.0")>
<Assembly: AssemblyVersion("1.14.0.0")>
<Assembly: AssemblyFileVersion("1.14.0.0")>

0 comments on commit d095c0d

Please sign in to comment.