/// <summary> /// It collect the downloadable files into param GDDownloader variable and /// it collect the unnecessary files into global deletableFiles variable. /// </summary> /// <param name="downloader"></param> /// <param name="localFolder"></param> /// <param name="parentId"></param> private void CollectDownSynchronizerData(GDDownloader downloader, string localFolder, string parentId) { List <string> unnecessaryFiles = getLocalFiles(localFolder); IEnumerable <Google.Apis.Drive.v3.Data.File> files = getGDFiles(parentId); foreach (Google.Apis.Drive.v3.Data.File file in files) { if (file.MimeType == "application/vnd.google-apps.folder") { string folderPath = localFolder + "\\" + file.Name; unnecessaryFiles.Remove(folderPath); CollectDownSynchronizerData(downloader, folderPath, file.Id); } else { if (file.FileExtension == "zip") { string fileName = localFolder + "\\" + file.Name.Substring(0, file.Name.Length - 4); if (unnecessaryFiles.Contains(fileName) && System.IO.File.GetLastWriteTime(fileName) >= file.ModifiedTime.Value) { unnecessaryFiles.Remove(fileName); } else { downloader.Add(new DownloadableFile(file, localFolder)); } } } } AddToDeletableFile(unnecessaryFiles); }