public void FindNewLocalObjects(string folder, ref List<string> addedFolders, ref List<string> addedFiles)
{
// Check files in this folder.
string[] files;
try
{
files = Directory.GetFiles(folder);
}
catch (Exception e)
{
Logger.Warn("Could not get the files list from folder: " + folder, e);
return;
}
foreach (string file in files)
{
// Check whether this file is present in database.
string filePath = Path.Combine(folder, file);
if ( ! database.ContainsLocalFile(filePath))
{
addedFiles.Add(filePath);
}
}
// Check folders and recurse.
string[] subFolders;
try
{
subFolders = Directory.GetDirectories(folder);
}
catch (Exception e)
{
Logger.Warn("Could not get the folders list from folder: " + folder, e);
return;
}
foreach (string subFolder in subFolders)
{
// Check whether this sub-folder is present in database.
string folderPath = Path.Combine(folder, subFolder);
if (database.ContainsLocalPath(folderPath))
{
// Recurse.
FindNewLocalObjects(folderPath, ref addedFolders, ref addedFiles);
}
else
{
// New folder, add to list and don't recurse.
addedFolders.Add(folderPath);
}
}
}