diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb
index b3a6a71..3dcc6f2 100644
--- a/GBM/Forms/frmGameManager.vb
+++ b/GBM/Forms/frmGameManager.vb
@@ -583,7 +583,7 @@ Public Class frmGameManager
sFileName = BackupFolder & CurrentBackupItem.FileName
If File.Exists(sFileName) Then
- lblBackupFileData.Text = Path.GetFileName(CurrentBackupItem.FileName) & " (" & mgrCommon.GetFileSize(sFileName) & ")"
+ lblBackupFileData.Text = Path.GetFileName(CurrentBackupItem.FileName) & " (" & mgrCommon.FormatDiskSpace(mgrCommon.GetFileSize(sFileName)) & ")"
Else
lblBackupFileData.Text = frmGameManager_ErrorNoBackupExists
End If
@@ -625,7 +625,7 @@ Public Class frmGameManager
btnDeleteBackup.Enabled = True
If File.Exists(sFileName) Then
- lblBackupFileData.Text = Path.GetFileName(CurrentBackupItem.FileName) & " (" & mgrCommon.GetFileSize(sFileName) & ")"
+ lblBackupFileData.Text = Path.GetFileName(CurrentBackupItem.FileName) & " (" & mgrCommon.FormatDiskSpace(mgrCommon.GetFileSize(sFileName)) & ")"
Else
lblBackupFileData.Text = frmGameManager_ErrorNoBackupExists
End If
diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb
index 567d922..486b92a 100644
--- a/GBM/Managers/mgrBackup.vb
+++ b/GBM/Managers/mgrBackup.vb
@@ -87,9 +87,25 @@ Public Class mgrBackup
Public Function CheckBackupPrereq(ByVal oGame As clsGame) As Boolean
Dim sBackupFile As String = oSettings.BackupFolder
+ Dim lAvailableSpace As Long = mgrCommon.GetAvailableDiskSpace(sBackupFile)
+ Dim lFolderSize As Long = mgrCommon.GetFolderSize(oGame.Path)
+
If oSettings.CreateSubFolder Then sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & oGame.Name & ".7z"
+ 'Show Available Space
+ RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_AvailableDiskSpace, mgrCommon.FormatDiskSpace(lAvailableSpace)), False, ToolTipIcon.Info, True)
+
+ 'Show Save Folder Size
+ RaiseEvent UpdateLog(mgrCommon.FormatString(mgrCommon_SavedGameFolderSize, New String() {oGame.Name, mgrCommon.FormatDiskSpace(lFolderSize)}), False, ToolTipIcon.Info, True)
+
+ If lFolderSize >= lAvailableSpace Then
+ If mgrCommon.ShowMessage(mgrBackup_ConfirmDiskSpace, MsgBoxStyle.YesNo) = MsgBoxResult.No Then
+ RaiseEvent UpdateLog(mgrBackup_ErrorDiskSpace, False, ToolTipIcon.Error, True)
+ Return False
+ End If
+ End If
+
If mgrRestore.CheckManifest(oGame.Name) Then
If mgrCommon.ShowMessage(mgrBackup_ConfirmManifestConflict, oGame.Name, MsgBoxStyle.YesNo) = MsgBoxResult.No Then
RaiseEvent UpdateLog(mgrBackup_ErrorManifestConflict, False, ToolTipIcon.Error, True)
@@ -223,7 +239,7 @@ Public Class mgrBackup
prs7z.WaitForExit()
If Not CancelOperation Then
If prs7z.ExitCode = 0 Then
- RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupComplete, New String() {oGame.Name, mgrCommon.GetFileSize(sBackupFile)}), False, ToolTipIcon.Info, True)
+ RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupComplete, New String() {oGame.Name, mgrCommon.FormatDiskSpace(mgrCommon.GetFileSize(sBackupFile))}), False, ToolTipIcon.Info, True)
bBackupCompleted = True
Else
RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_BackupWarnings, oGame.Name), True, ToolTipIcon.Warning, True)
diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb
index 79be112..dc59026 100644
--- a/GBM/Managers/mgrCommon.vb
+++ b/GBM/Managers/mgrCommon.vb
@@ -165,6 +165,77 @@ Public Class mgrCommon
Return eSyncFields And (Not eSyncField)
End Function
+ 'Get a file size
+ Public Shared Function GetFileSize(ByVal sFile As String) As Long
+ Dim oFileInfo As FileInfo
+ Dim dFileSize As Long = 0
+
+ Try
+ oFileInfo = New FileInfo(sFile)
+ dFileSize = oFileInfo.Length
+ Catch ex As Exception
+ 'Do Nothing
+ End Try
+
+ Return dFileSize
+ End Function
+
+ 'Calculate the current size of a folder
+ Public Shared Function GetFolderSize(ByVal sPath As String)
+ Dim oFolder As DirectoryInfo
+ Dim lSize As Long = 0
+
+ Try
+ oFolder = New DirectoryInfo(sPath)
+
+ 'Files
+ For Each fi As FileInfo In oFolder.GetFiles
+ lSize += fi.Length
+ Next
+
+ 'Sub Folders
+ For Each di As DirectoryInfo In oFolder.GetDirectories
+ lSize += GetFolderSize(di.FullName)
+ Next
+ Catch
+ 'Do Nothing
+ End Try
+
+ Return lSize
+ End Function
+
+ 'Format Disk Space Amounts
+ Public Shared Function FormatDiskSpace(ByVal lSize As Long)
+
+ Select Case lSize
+ Case >= 1125899906842624
+ Return FormatString(mgrCommon_PB, Math.Round(lSize / 1125899906842624, 2))
+ Case >= 1099511627776
+ Return FormatString(mgrCommon_TB, Math.Round(lSize / 1099511627776, 2))
+ Case >= 1073741824
+ Return FormatString(mgrCommon_GB, Math.Round(lSize / 1073741824, 2))
+ Case >= 1048576
+ Return FormatString(mgrCommon_MB, Math.Round(lSize / 1048576, 2))
+ Case >= 1024
+ Return FormatString(mgrCommon_KB, Math.Round(lSize / 1024, 2))
+ End Select
+
+ Return lSize
+ End Function
+
+ 'Get available disk space on a drive
+ Public Shared Function GetAvailableDiskSpace(ByVal sPath As String) As Long
+ Dim oDrive As DriveInfo
+ Dim lAvailableSpace As Long = 0
+ Try
+ oDrive = New DriveInfo(Path.GetPathRoot(sPath))
+ lAvailableSpace = oDrive.AvailableFreeSpace
+ Catch
+ 'Do Nothing
+ End Try
+ Return lAvailableSpace
+ End Function
+
'Delete file based on OS type
Public Shared Sub DeleteFile(ByVal sPath As String, Optional ByVal bRecycle As Boolean = True)
If File.Exists(sPath) Then
@@ -224,24 +295,6 @@ Public Class mgrCommon
End Try
End Sub
- 'Get a file size
- Public Shared Function GetFileSize(ByVal sFile As String) As String
- Dim oFileInfo As FileInfo
- Dim dFileSize As Double
-
- Try
- oFileInfo = New FileInfo(sFile)
- dFileSize = oFileInfo.Length
- If dFileSize > 1048576 Then
- Return FormatString(App_MB, Math.Round(dFileSize / 1048576, 2).ToString)
- Else
- Return FormatString(App_KB, Math.Round(dFileSize / 1024, 2).ToString)
- End If
- Catch ex As Exception
- Return String.Empty
- End Try
- End Function
-
'Handles no extra parameters
Public Shared Function ShowMessage(ByVal sMsg As String, ByVal oType As MsgBoxStyle) As MsgBoxResult
Dim oResult As MsgBoxResult
diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb
index 72b2bd9..046eedc 100644
--- a/GBM/My Project/Resources.Designer.vb
+++ b/GBM/My Project/Resources.Designer.vb
@@ -96,24 +96,6 @@ Namespace My.Resources
End Get
End Property
- '''
- ''' Looks up a localized string similar to [PARAM] KB.
- '''
- Friend ReadOnly Property App_KB() As String
- Get
- Return ResourceManager.GetString("App_KB", resourceCulture)
- End Get
- End Property
-
- '''
- ''' Looks up a localized string similar to [PARAM] MB.
- '''
- Friend ReadOnly Property App_MB() As String
- Get
- Return ResourceManager.GetString("App_MB", resourceCulture)
- End Get
- End Property
-
'''
''' Looks up a localized string similar to Game Backup Monitor.
'''
@@ -4510,6 +4492,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to You may not have enough disk space available to perform a backup.[BR][BR]Do you want to continue anyway?.
+ '''
+ Friend ReadOnly Property mgrBackup_ConfirmDiskSpace() As String
+ Get
+ Return ResourceManager.GetString("mgrBackup_ConfirmDiskSpace", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to The manifest shows the backup folder contains a backup for [PARAM] that has not been restored on this computer.[BR][BR]Do you want to overwrite this file anyway?.
'''
@@ -4528,6 +4519,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Backup aborted due to lack of disk space..
+ '''
+ Friend ReadOnly Property mgrBackup_ErrorDiskSpace() As String
+ Get
+ Return ResourceManager.GetString("mgrBackup_ErrorDiskSpace", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to An error occured creating a file list: [PARAM].
'''
@@ -4609,6 +4609,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Available Disk Space: [PARAM].
+ '''
+ Friend ReadOnly Property mgrCommon_AvailableDiskSpace() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_AvailableDiskSpace", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to An error has occured writing the text file.[BR][BR][PARAM].
'''
@@ -4627,6 +4636,33 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to [PARAM] GB.
+ '''
+ Friend ReadOnly Property mgrCommon_GB() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_GB", resourceCulture)
+ End Get
+ End Property
+
+ '''
+ ''' Looks up a localized string similar to [PARAM] KB.
+ '''
+ Friend ReadOnly Property mgrCommon_KB() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_KB", resourceCulture)
+ End Get
+ End Property
+
+ '''
+ ''' Looks up a localized string similar to [PARAM] MB.
+ '''
+ Friend ReadOnly Property mgrCommon_MB() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_MB", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to No.
'''
@@ -4636,6 +4672,33 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to [PARAM] PB.
+ '''
+ Friend ReadOnly Property mgrCommon_PB() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_PB", resourceCulture)
+ End Get
+ End Property
+
+ '''
+ ''' Looks up a localized string similar to [PARAM] Save Folder Size: [PARAM].
+ '''
+ Friend ReadOnly Property mgrCommon_SavedGameFolderSize() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_SavedGameFolderSize", resourceCulture)
+ End Get
+ End Property
+
+ '''
+ ''' Looks up a localized string similar to [PARAM] TB.
+ '''
+ Friend ReadOnly Property mgrCommon_TB() As String
+ Get
+ Return ResourceManager.GetString("mgrCommon_TB", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to Yes.
'''
diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx
index 8a29017..8976911 100644
--- a/GBM/My Project/Resources.resx
+++ b/GBM/My Project/Resources.resx
@@ -424,12 +424,6 @@
There are unsaved changes on this form. Do you want to save?
-
- [PARAM] KB
-
-
- [PARAM] MB
-
[PARAM] ([PARAM])
@@ -1762,4 +1756,31 @@
The backup file for [PARAM] has no checksum, it cannot be automatically restored.
+
+ You may not have enough disk space available to perform a backup.[BR][BR]Do you want to continue anyway?
+
+
+ Backup aborted due to lack of disk space.
+
+
+ Available Disk Space: [PARAM]
+
+
+ [PARAM] GB
+
+
+ [PARAM] KB
+
+
+ [PARAM] MB
+
+
+ [PARAM] PB
+
+
+ [PARAM] Save Folder Size: [PARAM]
+
+
+ [PARAM] TB
+
\ No newline at end of file