filechangeinfo.cs

来自「代码模版 codtemplate」· CS 代码 · 共 50 行

CS
50
字号
using System;
using System.IO;

namespace CodeTemplate
{
	internal class FileChangeInfo
	{
		public FileChangeInfo(String filePath)
		{
			m_filePath = filePath;
			m_timestamp = DateTime.MinValue;
		}

		public String FilePath
		{
			get { return m_filePath; }
		}

		public Boolean Changed
		{
			get { return m_timestamp < this.LastWriteTime; }
		}

		private DateTime LastWriteTime
		{
			get 
			{
				try
				{
					FileInfo fi = new FileInfo(this.FilePath);
					return fi.LastWriteTime;
				}

				catch(Exception)
				{
					return DateTime.MinValue;
				}
			}
		}

		public void Refresh()
		{
			m_timestamp = this.LastWriteTime;
		}

		private String m_filePath;
		private DateTime m_timestamp;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?