本文整理汇总了C#中System.IO.FileInfo.GetCreationTimeUtc方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.GetCreationTimeUtc方法的具体用法?C# FileInfo.GetCreationTimeUtc怎么用?C# FileInfo.GetCreationTimeUtc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.GetCreationTimeUtc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GetFileCreationTimeUtc
public DateTime? GetFileCreationTimeUtc(string filePath, bool fallback)
{
var appender = GetAppender(filePath);
DateTime? result = null;
if (appender != null)
{
try
{
result = appender.GetFileCreationTimeUtc();
}
catch (Exception ex)
{
InternalLogger.Error(ex, "Failed to get file creation time for file '{0}'.", appender.FileName);
InvalidateAppender(appender.FileName);
throw;
}
}
if (result == null && fallback)
{
var fileInfo = new FileInfo(filePath);
if (fileInfo.Exists)
{
return fileInfo.GetCreationTimeUtc();
}
}
return result;
}
示例4: GetFileCreationTimeUtc
public DateTime? GetFileCreationTimeUtc(string filePath, bool fallback)
{
var appender = GetAppender(filePath);
DateTime? result = null;
if (appender != null)
result = appender.GetFileCreationTimeUtc();
if (result == null && fallback)
{
var fileInfo = new FileInfo(filePath);
if (fileInfo.Exists)
{
return fileInfo.GetCreationTimeUtc();
}
}
return result;
}
示例5: GetFileCreationTimeUtc
/// <summary>
/// Gets the creation time for a file associated with the appender. The time returned is in Coordinated Universal
/// Time [UTC] standard.
/// </summary>
/// <returns>The file creation time.</returns>
public override DateTime? GetFileCreationTimeUtc()
{
FileInfo fileInfo = new FileInfo(FileName);
if (fileInfo.Exists)
{
return fileInfo.GetCreationTimeUtc();
}
return null;
}