Skip to content

Commit

Permalink
fix unhandled exception if recent path is invalid, when trying to sav…
Browse files Browse the repository at this point in the history
…e a file [#59]
  • Loading branch information
t0815 committed Oct 27, 2024
1 parent bf392e0 commit 6bd1f10
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MyCBZ/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
<applicationSettings>
<Win_CBZ.Win_CBZSettings>
<setting name="InstalledVersion" serializeAs="String">
<value>0.22.180b</value>
<value>0.22.181b</value>
</setting>
<setting name="RenamerPlaceholders" serializeAs="Xml">
<value>
Expand Down
30 changes: 26 additions & 4 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,20 @@ private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)

if (Win_CBZSettings.Default.RecentSavedArchivePath != null && Win_CBZSettings.Default.RecentSavedArchivePath.Length > 0)
{
recentPath = new LocalFile(Win_CBZSettings.Default.RecentSavedArchivePath);
try
{
recentPath = new LocalFile(Win_CBZSettings.Default.RecentSavedArchivePath);
SaveArchiveDialog.InitialDirectory = Win_CBZSettings.Default.RecentSavedArchivePath;
} catch (ApplicationException ae)
{
if (ae.ShowErrorDialog)
{

SaveArchiveDialog.InitialDirectory = Win_CBZSettings.Default.RecentSavedArchivePath;
}
} catch (ArgumentNullException ane)
{

}
}

DialogResult saveDialogResult = SaveArchiveDialog.ShowDialog();
Expand All @@ -549,9 +560,20 @@ private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
PagesList.SelectedItem = null;
if (Program.ProjectModel.SaveAs(SaveArchiveDialog.FileName, ZipArchiveMode.Update, MetaDataVersionFlavorHandler.GetInstance().HandlePageIndexVersion()))
{
recentPath = new LocalFile(SaveArchiveDialog.FileName);
try
{
recentPath = new LocalFile(SaveArchiveDialog.FileName);
Win_CBZSettings.Default.RecentSavedArchivePath = recentPath.FilePath;
} catch (ApplicationException ae)
{
if (ae.ShowErrorDialog)
{

Win_CBZSettings.Default.RecentSavedArchivePath = recentPath.FilePath;
}
} catch (ArgumentNullException ane)
{

}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions MyCBZ/Models/LocalFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,20 @@ internal class LocalFile

public LocalFile(String fileName)
{
if (fileName == null)
{
throw new ArgumentNullException(nameof(fileName));
}

FullPath = fileName;
LocalFileInfo = new FileInfo(fileName);
FileName = LocalFileInfo.Name;
Name = Path.GetFileNameWithoutExtension(fileName);
if (LocalFileInfo.Directory == null)
{
throw new ApplicationException("LocalFile: Invalid Directory ('" + fileName + "')", true);
}

FilePath = LocalFileInfo.Directory.FullName + Path.DirectorySeparatorChar;
try
{
Expand Down
4 changes: 2 additions & 2 deletions MyCBZ/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.180")]
[assembly: AssemblyFileVersion("0.22.180")]
[assembly: AssemblyVersion("0.22.181")]
[assembly: AssemblyFileVersion("0.22.181")]
[assembly: NeutralResourcesLanguage("en")]
2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion MyCBZ/Win_CBZSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">%APPDATA%\WIN_CBZ\Temp\</Value>
</Setting>
<Setting Name="InstalledVersion" Type="System.String" Scope="Application">
<Value Profile="(Default)">0.22.180b</Value>
<Value Profile="(Default)">0.22.181b</Value>
</Setting>
<Setting Name="RenamerPlaceholders" Type="System.Collections.Specialized.StringCollection" Scope="Application">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Microsoft Visual Studio [Community] 2022 (64-Bit)

## Latest Release

v0.22.180b released!
v0.22.181b released!


>[!IMPORTANT]
Expand Down
8 changes: 4 additions & 4 deletions Win_CBZ-Setup/Win_CBZ-Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Win_CBZ"
"ProductCode" = "8:{4625E64F-63F5-47AA-B42B-C2DE480A4C96}"
"PackageCode" = "8:{19AA5FAF-43FD-4052-A489-3D92FD365C23}"
"ProductCode" = "8:{575CBDE8-0130-4D4F-A625-F70475008458}"
"PackageCode" = "8:{04E43D49-0C66-4047-A8BA-49F190B8CC8E}"
"UpgradeCode" = "8:{66FAEF81-1CAE-4971-9E0F-796310EFEA5E}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:0.22.180"
"ProductVersion" = "8:0.22.181"
"Manufacturer" = "8:Trash_s0Ft"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down Expand Up @@ -808,7 +808,7 @@
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_1DAB07B3E40248E0B54293E16EE30178"
{
"SourcePath" = "8:..\\MyCBZ\\obj\\x64\\Debug\\net8.0-windows7.0\\apphost.exe"
"SourcePath" = "8:..\\MyCBZ\\obj\\x64\\Release\\net8.0-windows7.0\\apphost.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_381C2AC7AD384E1488C6014F95032920"
Expand Down

0 comments on commit 6bd1f10

Please sign in to comment.