Added return object.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-08-22 11:11:17 -06:00
parent 691813838c
commit 364a13226a
3 changed files with 113 additions and 49 deletions

View File

@@ -15,6 +15,7 @@ namespace CarCareTracker.Helper
List<string> GetLanguages();
int ClearTempFolder();
int ClearUnlinkedThumbnails(List<string> linkedImages);
int ClearUnlinkedDocuments(List<string> linkedDocuments);
}
public class FileHelper : IFileHelper
{
@@ -349,5 +350,23 @@ namespace CarCareTracker.Helper
}
return filesDeleted;
}
public int ClearUnlinkedDocuments(List<string> linkedDocuments)
{
int filesDeleted = 0;
var documentPath = GetFullFilePath("documents", false);
if (Directory.Exists(documentPath))
{
var files = Directory.GetFiles(documentPath);
foreach (var file in files)
{
if (!linkedDocuments.Contains(Path.GetFileName(file)))
{
File.Delete(file);
filesDeleted++;
}
}
}
return filesDeleted;
}
}
}