本文整理汇总了C#中System.IO.FileInfo.GetLastWriteTimeUtc方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.GetLastWriteTimeUtc方法的具体用法?C# FileInfo.GetLastWriteTimeUtc怎么用?C# FileInfo.GetLastWriteTimeUtc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.GetLastWriteTimeUtc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFileCharacteristics
/// <summary>
/// Gets the information about a file.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="fileHandle">The file handle.</param>
/// <returns>The file characteristics, if the file information was retrieved successfully, otherwise null.</returns>
public override FileCharacteristics GetFileCharacteristics(string fileName, IntPtr fileHandle)
{
var fileInfo = new FileInfo(fileName);
if (fileInfo.Exists)
{
return new FileCharacteristics(fileInfo.GetCreationTimeUtc(), fileInfo.GetLastWriteTimeUtc(), fileInfo.Length);
}
else
return null;
}
示例2: GetFileCharacteristics
/// <summary>
/// Gets the information about a file.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="fileStream">The file stream.</param>
/// <returns>The file characteristics, if the file information was retrieved successfully, otherwise null.</returns>
public override FileCharacteristics GetFileCharacteristics(string fileName, FileStream fileStream)
{
if (!string.IsNullOrEmpty(fileName))
{
var fileInfo = new FileInfo(fileName);
if (fileInfo.Exists)
{
return new FileCharacteristics(fileInfo.GetCreationTimeUtc(), fileInfo.GetLastWriteTimeUtc(), fileInfo.Length);
}
}
return null;
}
示例3: SingleProcessFileAppender
/// <summary>
/// Initializes a new instance of the <see cref="SingleProcessFileAppender" /> class.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="parameters">The parameters.</param>
public SingleProcessFileAppender(string fileName, ICreateFileParameters parameters) : base(fileName, parameters)
{
if (CaptureLastWriteTime)
{
var fileInfo = new FileInfo(fileName);
if (fileInfo.Exists)
{
FileTouched(fileInfo.GetLastWriteTimeUtc());
}
else
{
FileTouched();
}
}
this.file = CreateFileStream(false);
}
示例4: CountingSingleProcessFileAppender
/// <summary>
/// Initializes a new instance of the <see cref="CountingSingleProcessFileAppender" /> class.
/// </summary>
/// <param name="fileName">Name of the file.</param>
/// <param name="parameters">The parameters.</param>
public CountingSingleProcessFileAppender(string fileName, ICreateFileParameters parameters)
: base(fileName, parameters)
{
var fileInfo = new FileInfo(fileName);
if (fileInfo.Exists)
{
if (CaptureLastWriteTime)
{
FileTouched(fileInfo.GetLastWriteTimeUtc());
}
this.currentFileLength = fileInfo.Length;
}
else
{
FileTouched();
this.currentFileLength = 0;
}
this.file = this.CreateFileStream(false);
}
示例5: GetFileLastWriteTimeUtc
public DateTime? GetFileLastWriteTimeUtc(string filePath, bool fallback)
{
var appender = GetAppender(filePath);
DateTime? result = null;
if (appender != null)
{
try
{
result = appender.GetFileLastWriteTimeUtc();
}
catch (Exception ex)
{
InternalLogger.Error(ex, "Failed to get last write time for file '{0}'.", appender.FileName);
InvalidateAppender(appender.FileName);
throw;
}
}
if (result == null && fallback)
{
var fileInfo = new FileInfo(filePath);
if (fileInfo.Exists)
{
return fileInfo.GetLastWriteTimeUtc();
}
}
return result;
}
示例6: GetFileLastWriteTimeUtc
public DateTime? GetFileLastWriteTimeUtc(string filePath, bool fallback)
{
var appender = GetAppender(filePath);
DateTime? result = null;
if (appender != null)
result = appender.GetFileLastWriteTimeUtc();
if (result == null && fallback)
{
var fileInfo = new FileInfo(filePath);
if (fileInfo.Exists)
{
return fileInfo.GetLastWriteTimeUtc();
}
}
return result;
}
示例7: GetFileLastWriteTimeUtc
/// <summary>
/// Gets the last time the file associated with the appeander is written. The time returned is in Coordinated
/// Universal Time [UTC] standard.
/// </summary>
/// <returns>The time the file was last written to.</returns>
public override DateTime? GetFileLastWriteTimeUtc()
{
FileInfo fileInfo = new FileInfo(FileName);
if (fileInfo.Exists)
{
return fileInfo.GetLastWriteTimeUtc();
}
return null;
}