Skip to content

Commit ffa31c7

Browse files
committed
Reworked folder size parsing after compression to account for variations in regional formatting
1 parent 15edd5b commit ffa31c7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

WindowsApp1/Compact.vb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Imports System.IO
22
Imports System.Runtime.InteropServices
3+
Imports System.Text.RegularExpressions
34
Imports Ookii.Dialogs 'Uses Ookii Dialogs for the non-archaic filebrowser dialog. http://www.ookii.org/Software/Dialogs
45

56
Public Class Compact
@@ -379,16 +380,18 @@ Public Class Compact
379380
Private Sub CalculateSaving() 'Calculations for all the relevant information after compression is completed. All the data is parsed from the console ouput using basic strings, but because that occurs on a different thread, information is stored to variables first (The Status Monitors at the top) then those values are used.
380381

381382

382-
Dim oldFolderSize = byteComparisonRaw.Substring _
383-
(0, byteComparisonRaw.IndexOf("t")).Trim.Replace(",", "")
384-
383+
'Dim oldFolderSize = byteComparisonRaw.Substring _
384+
'(0, byteComparisonRaw.IndexOf("t")).Trim.Replace(",", "")
385+
Dim oldFolderSize = Long.Parse(Regex.Replace(byteComparisonRaw.Substring _
386+
(0, byteComparisonRaw.IndexOf("t")), "[^\d]", ""))
385387

386388
Dim newFolderSizem1 = byteComparisonRaw.Substring _
387389
(byteComparisonRaw.LastIndexOf("n"c) + 1)
388390

389-
Dim newfoldersize = newFolderSizem1.Substring _
390-
(0, newFolderSizem1.Length - 7).Trim.Replace(",", "")
391-
391+
'Dim newfoldersize = newFolderSizem1.Substring _
392+
' (0, newFolderSizem1.Length - 7).Trim.Replace(",", "")
393+
Dim newfoldersize = Long.Parse(Regex.Replace(newFolderSizem1.Substring _
394+
(0, newFolderSizem1.Length - 7), "[^\d]", ""))
392395

393396
origSizeLabel.Text = GetOutputSize(oldFolderSize, True)
394397
compressedSizeLabel.Text = GetOutputSize(newfoldersize, True)

0 commit comments

Comments
 (0)