Create books directory if not found (#542)
This commit is contained in:
parent
565c84c4ab
commit
99687e968e
1 changed files with 13 additions and 2 deletions
|
|
@ -16,11 +16,22 @@ namespace LibationFileManager
|
|||
if (!Directory.Exists(Path.GetDirectoryName(settingsFile)) || !File.Exists(settingsFile))
|
||||
return false;
|
||||
|
||||
var pDic = new PersistentDictionary(settingsFile, isReadOnly: true);
|
||||
var pDic = new PersistentDictionary(settingsFile, isReadOnly: false);
|
||||
|
||||
var booksDir = pDic.GetString(nameof(Books));
|
||||
if (booksDir is null || !Directory.Exists(booksDir))
|
||||
return false;
|
||||
{
|
||||
booksDir = Path.Combine(Path.GetDirectoryName(settingsFile), nameof(Books));
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(booksDir);
|
||||
|
||||
pDic.SetString(nameof(Books), booksDir);
|
||||
|
||||
return booksDir is not null && Directory.Exists(booksDir);
|
||||
}
|
||||
catch { return false; }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue