internal static DateTime GetLastWriteTimeUtc(string fullPath) { DateTime minValue = DateTime.MinValue; WIN32_FILE_ATTRIBUTE_DATA lpFileInformation = new WIN32_FILE_ATTRIBUTE_DATA(); if (GetFileAttributesEx(fullPath, 0, ref lpFileInformation)) { long fileTime = (lpFileInformation.ftLastWriteTimeHigh << 0x20) | lpFileInformation.ftLastWriteTimeLow; minValue = DateTime.FromFileTimeUtc(fileTime); } return minValue; }
internal static DateTime GetLastWriteTimeUtc(string fullPath) { DateTime minValue = DateTime.MinValue; WIN32_FILE_ATTRIBUTE_DATA lpFileInformation = new WIN32_FILE_ATTRIBUTE_DATA(); if (GetFileAttributesEx(fullPath, 0, ref lpFileInformation)) { long fileTime = (lpFileInformation.ftLastWriteTimeHigh << 0x20) | lpFileInformation.ftLastWriteTimeLow; minValue = DateTime.FromFileTimeUtc(fileTime); } return(minValue); }
/// <summary> /// Get the last write time in utc of the fullpath to the file. /// If the file does not exist, then DateTime.MinValue is returned /// </summary> /// <param name="fullPath">Full path to the file in the filesystem</param> /// <returns></returns> internal static DateTime GetLastWriteTimeUtc(string fullPath) { DateTime fileModifiedTime = DateTime.MinValue; WIN32_FILE_ATTRIBUTE_DATA data = new WIN32_FILE_ATTRIBUTE_DATA(); bool success = false; success = NativeMethods.GetFileAttributesEx(fullPath, 0, ref data); if (success) { long dt = ((long)(data.ftLastWriteTimeHigh) << 32) | ((long)data.ftLastWriteTimeLow); fileModifiedTime = DateTime.FromFileTimeUtc(dt); } return fileModifiedTime; }
/// <summary> /// Get the last write time in utc of the fullpath to the file. /// If the file does not exist, then DateTime.MinValue is returned /// </summary> /// <param name="fullPath">Full path to the file in the filesystem</param> /// <returns></returns> internal static DateTime GetLastWriteTimeUtc(string fullPath) { DateTime fileModifiedTime = DateTime.MinValue; WIN32_FILE_ATTRIBUTE_DATA data = new WIN32_FILE_ATTRIBUTE_DATA(); bool success = false; success = NativeMethods.GetFileAttributesEx(fullPath, 0, ref data); if (success) { long dt = ((long)(data.ftLastWriteTimeHigh) << 32) | ((long)data.ftLastWriteTimeLow); fileModifiedTime = DateTime.FromFileTimeUtc(dt); } return(fileModifiedTime); }
internal static extern bool GetFileAttributesEx(string name, int fileInfoLevel, ref WIN32_FILE_ATTRIBUTE_DATA lpFileInformation);