当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.GetLastWriteTimeUtc方法代码示例

本文整理汇总了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;
 }
开发者ID:daniefer,项目名称:NLog,代码行数:16,代码来源:PortableFileCharacteristicsHelper.cs

示例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;
 }
开发者ID:NLog,项目名称:NLog,代码行数:18,代码来源:PortableFileCharacteristicsHelper.cs

示例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);
 }
开发者ID:ie-zero,项目名称:NLog,代码行数:21,代码来源:SingleProcessFileAppender.cs

示例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);
        }
开发者ID:NLog,项目名称:NLog,代码行数:25,代码来源:CountingSingleProcessFileAppender.cs

示例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;
        }
开发者ID:NLog,项目名称:NLog,代码行数:28,代码来源:FileAppenderCache.cs

示例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;
        }
开发者ID:ie-zero,项目名称:NLog,代码行数:17,代码来源:FileAppenderCache.cs

示例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;
 }
开发者ID:NLog,项目名称:NLog,代码行数:14,代码来源:RetryingMultiProcessFileAppender.cs


注:本文中的System.IO.FileInfo.GetLastWriteTimeUtc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。