2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-07-03 01:03:41 -04:00

2 Bug Fixes (#112)

Add a try-catch in ReadAllLines to handle a read failure if a file is locked.
Add a check for a non-existing export folder when exporting and prompt for new path if it doesn't exist.
This commit is contained in:
F K
2023-04-30 11:49:22 -04:00
committed by GitHub
parent 5bbf2f50de
commit 639ad72fb4
2 changed files with 11 additions and 4 deletions

View File

@ -420,13 +420,20 @@ namespace Observatory
private List<string> ReadAllLines(string path)
{
var lines = new List<string>();
using (StreamReader file = new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
try
{
while (!file.EndOfStream)
using (StreamReader file = new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
lines.Add(file.ReadLine());
while (!file.EndOfStream)
{
lines.Add(file.ReadLine());
}
}
}
catch (IOException ioEx)
{
ReportErrors(new List<(Exception, string, string)>() { (ioEx, path, "<reading all lines>") });
}
return lines;
}