public static FindMoreRecentLastWriteTime ( |
||
fileNames | A collection of filenames to check the last write time against. | |
targetLastWriteTime | System.DateTime | The datetime to compare against. |
Результат | string |
public static string FindMoreRecentLastWriteTime(StringCollection fileNames, DateTime targetLastWriteTime)
{
foreach (string fileName in fileNames) {
// only check fully file names that have a full path
if (Path.IsPathRooted(fileName)) {
FileInfo fileInfo = new FileInfo(fileName);
if (!fileInfo.Exists) {
logger.Info(string.Format(CultureInfo.InvariantCulture, "File '{0}' no longer exist (so the target might need to be updated)", fileName, targetLastWriteTime));
return fileName;
}
if (fileInfo.LastWriteTime > targetLastWriteTime) {
logger.Info(string.Format(CultureInfo.InvariantCulture, "'{0}' was newer than {1}", fileName, targetLastWriteTime));
return fileName;
}
}
}
return null;
}
FileSet::FindMoreRecentLastWriteTime ( string fileName, System.DateTime targetLastWriteTime ) : string |
/// <summary> /// Determines if a file has a more recent last write time than the /// given time, or no longer exists. /// </summary> /// <param name="fileName">A file to check the last write time against.</param> /// <param name="targetLastWriteTime">The datetime to compare against.</param> /// <returns> /// The name of the file that has a last write time greater than /// <paramref name="targetLastWriteTime" /> or that no longer exists; /// otherwise, <see langword="null" />. /// </returns> public static string FindMoreRecentLastWriteTime(string fileName, DateTime targetLastWriteTime) { StringCollection fileNames = new StringCollection(); fileNames.Add(fileName); return(FileSet.FindMoreRecentLastWriteTime(fileNames, targetLastWriteTime)); }