SIL.FieldWorks.Common.Framework.FwApp.CollectMovableFilesFromFolder C# (CSharp) Method

CollectMovableFilesFromFolder() private static method

Build a list of files that can be moved (or copied) to the new LinkedFiles root directory.
private static CollectMovableFilesFromFolder ( ICmFolder folder, List rgFilesToMove, string sOldRootDir, string sNewRootDir ) : void
folder ICmFolder
rgFilesToMove List
sOldRootDir string
sNewRootDir string
return void
		private static void CollectMovableFilesFromFolder(ICmFolder folder,
			List<string> rgFilesToMove, string sOldRootDir, string sNewRootDir)
		{
			foreach (var file in folder.FilesOC)
			{
				string sFilepath = file.InternalPath;
				//only select files which have relative paths so they are in the LinkedFilesRootDir
				if (!Path.IsPathRooted(sFilepath))
				{
					// Don't put the same file in more than once!
					if (rgFilesToMove.Contains(sFilepath))
						continue;
					var sOldFilePath = Path.Combine(sOldRootDir, sFilepath);
					if (FileUtils.TrySimilarFileExists(sOldFilePath, out sOldFilePath))
					{
						var sNewFilePath= Path.Combine(sNewRootDir, sFilepath);
						if (FileUtils.TrySimilarFileExists(sNewFilePath, out sNewFilePath))
						{
							//if the file exists in the destination LinkedFiles location, then only copy/move it if
							//file in the source location is newer.
							var dateTimeOfFileSourceFile = File.GetLastWriteTime(sOldFilePath);
							var dateTimeOfFileDestinationFile = File.GetLastWriteTime(sNewFilePath);
							if (dateTimeOfFileSourceFile > dateTimeOfFileDestinationFile)
								rgFilesToMove.Add(sFilepath);
						}
						else
						{
							//if the file does not exist in the destination LinkeFiles location then copy/move it.
							rgFilesToMove.Add(sFilepath);
						}
					}
				}
			}
			foreach (var sub in folder.SubFoldersOC)
				CollectMovableFilesFromFolder(sub, rgFilesToMove, sOldRootDir, sNewRootDir);
		}