Added return object.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user