Skip to content

Commit

Permalink
Dispose the file streams immediately after its done
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Aug 23, 2024
1 parent 8fbb3b9 commit a7d9282
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions WalkerSim/Simulation.LoadSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ public bool Save(string filePath)
{
try
{
var fs = new FileStream(filePath, FileMode.Create);
return Save(fs);
using (var fs = new FileStream(filePath, FileMode.Create))
{
return Save(fs);
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -289,8 +291,10 @@ public bool Load(string filePath)
{
try
{
var fs = new FileStream(filePath, FileMode.Open);
return Load(fs);
using (var fs = new FileStream(filePath, FileMode.Open))
{
return Load(fs);
}
}
catch (Exception ex)
{
Expand Down

0 comments on commit a7d9282

Please sign in to comment.