Avoid errors on file system when populating entries

dhcp-server
Pat Hartl 2023-09-11 17:57:24 -05:00
parent bf63813e90
commit d54bf3c4e8
1 changed files with 27 additions and 19 deletions

View File

@ -333,32 +333,40 @@
{
if (Directory.Exists(entry))
{
var info = new DirectoryInfo(entry);
var directory = new FileManagerDirectory
try
{
Path = entry,
Name = entry.Substring(Path.Path.Length).TrimStart(separator),
ModifiedOn = info.LastWriteTime,
CreatedOn = info.CreationTime,
};
var info = new DirectoryInfo(entry);
var directory = new FileManagerDirectory
{
Path = entry,
Name = entry.Substring(Path.Path.Length).TrimStart(separator),
ModifiedOn = info.LastWriteTime,
CreatedOn = info.CreationTime,
};
if (EntryVisible.Invoke(directory))
Entries.Add(directory);
if (EntryVisible.Invoke(directory))
Entries.Add(directory);
}
catch { }
}
else
{
var info = new FileInfo(entry);
var file = new FileManagerFile
try
{
Path = entry,
Name = System.IO.Path.GetFileName(entry),
ModifiedOn = info.LastWriteTime,
CreatedOn = info.CreationTime,
Size = info.Length
};
var info = new FileInfo(entry);
var file = new FileManagerFile
{
Path = entry,
Name = System.IO.Path.GetFileName(entry),
ModifiedOn = info.LastWriteTime,
CreatedOn = info.CreationTime,
Size = info.Length
};
if (EntryVisible.Invoke(file))
Entries.Add(file);
if (EntryVisible.Invoke(file))
Entries.Add(file);
}
catch { }
}
}
}