private Boolean IsFolderModified(JObject fileObj, string directoryPath) { //Fetch all files in this directory string[] filePaths = FileSystemHelpers.GetFiles(directoryPath, "*"); if (filePaths != null) { foreach (string filePath in filePaths) { Console.WriteLine(filePath); //If manifest does not contain an entry for this file //It means the file was newly added //We need to scan as this is a modification JToken val = null; if (!fileObj.TryGetValue(filePath, out val)) { return(true); } //Modified time in manifest String lastModTime = (string)fileObj[filePath]; //Current modified time String currModTime = FileSystemHelpers.GetDirectoryLastWriteTimeUtc(filePath).ToString(); //If they are different //It means file has been modified after last scan if (!currModTime.Equals(lastModTime)) { return(true); } } } //Fetch all the child directories of this directory string[] direcPaths = FileSystemHelpers.GetDirectories(directoryPath); if (direcPaths != null) { //Do recursive comparison of all files in the child directories foreach (string direcPath in direcPaths) { if (IsFolderModified(fileObj, direcPath)) { return(true); } } } //No modifications found return(false); }
private void ModifyManifestFile(JObject fileObj, string directoryPath) { //Get all files in this directory string[] filePaths = FileSystemHelpers.GetFiles(directoryPath, "*"); foreach (string filePath in filePaths) { //Get last modified timestamp of this file String timeString = FileSystemHelpers.GetDirectoryLastWriteTimeUtc(filePath).ToString(); //Add it as an entry into the manifest fileObj.Add(filePath, timeString); } //Get all child directories of this directory string[] direcPaths = FileSystemHelpers.GetDirectories(directoryPath); //Do a recursive call to add files of child directories to manifest foreach (string direcPath in direcPaths) { ModifyManifestFile(fileObj, direcPath); } }